LD 5 лет назад
Родитель
Сommit
997e39bb5f
32 измененных файлов с 651 добавлено и 620 удалено
  1. 137 0
      app/Http/Controllers/InventoryAccountController.php
  2. 58 126
      app/Http/Controllers/InventoryController.php
  3. 9 9
      app/Http/Controllers/InventoryMissionController.php
  4. 6 6
      app/InventoryAccount.php
  5. 2 2
      app/InventoryAccountMission.php
  6. 81 64
      app/Services/InventoryAccountService.php
  7. 2 2
      database/factories/InventoryFactory.php
  8. 3 3
      database/factories/InventoryMissionFactory.php
  9. 49 0
      database/migrations/2020_08_26_093946_change_inventory_missions_to_inventory_account_missions.php
  10. 41 0
      database/migrations/2020_08_26_094015_change_inventories_to_inventory_accounts.php
  11. 2 2
      public/js/app.js
  12. 0 199
      resources/views/inventory/statement/allInventory.blade.php
  13. 4 0
      resources/views/inventory/statement/changeInventory.blade.php
  14. 6 5
      resources/views/inventory/stockInventory/inventoryMission.blade.php
  15. 100 53
      resources/views/inventory/stockInventory/mission.blade.php
  16. 8 7
      routes/web.php
  17. 27 0
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_ConditionSearchTest.php
  18. 14 12
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php
  19. 9 9
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateMissionTest.php
  20. 6 6
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_GetTest.php
  21. 8 8
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_PaginateTest.php
  22. 11 11
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SearchStockInventoryRecordTest.php
  23. 10 10
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SomeTest.php
  24. 10 10
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_StockInventoryTest.php
  25. 0 27
      tests/Inventory/Services/InventoryService/InventoryService_ConditionSearchTest.php
  26. 8 9
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_CreateStockInventoryMissionTest.php
  27. 3 3
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_DeleteStockInventoryMissionTest.php
  28. 10 10
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_EnterStockInventoryTest.php
  29. 1 1
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_MissionTest.php
  30. 7 7
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_SearchStockInventoryRecordTest.php
  31. 7 7
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_StockInventoryTest.php
  32. 12 12
      tests/Inventory/model/InventoryAccountTest.php

+ 137 - 0
app/Http/Controllers/InventoryAccountController.php

@@ -0,0 +1,137 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Exports\Export;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Owner;
+use App\Services\InventoryAccountService;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Gate;
+use Maatwebsite\Excel\Facades\Excel;
+
+class InventoryAccountController extends Controller
+{
+    public function __construct()
+    {
+        app()->singleton('inventoryService',InventoryAccountService::class);
+    }
+
+    //创建盘点任务
+    public function createStockInventoryMission(Request $request){
+        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+//        $date_start=$request->input('formData.date_start');
+//        $date_end=$request->input('formData.date_end');
+//        $ownerId=$request->input('formData.owner_id')[0];
+        $date_start=$request->input('date_start');
+        $date_end=$request->input('date_end');
+        $ownerId=$request->input('owner_id');
+        $inventoryAccount=app('inventoryService')->createMission($date_start,$date_end,$ownerId);
+        $inventoryAccount=InventoryAccount::with('owner')->find($inventoryAccount->id);
+        if (is_null($inventoryAccount)) return ['success'=>false,'data'=>'参数错误!'];
+        return ['success'=>true,'data'=>$inventoryAccount];
+    }
+    //删除盘点任务
+    public function deleteStockInventoryMission($id){
+        if(!Gate::allows('库存管理-盘点')){return['success'=>0,'status'=>'没有权限'];}
+        if(is_null($id)){return ['success'=>false,'data'=>'传入id为空'];}
+        $inventoryAccount=InventoryAccount::where('id',$id)->delete();
+        return ['success'=>true,'data'=>$inventoryAccount];
+    }
+
+
+
+    //盘点-任务页面
+    public function mission(Request $request){
+        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+        $paginateParams = $request->input();
+        $queryParam=$request->all();
+        $inventoryAccounts=app('inventoryService')->paginate($queryParam);
+        $owners=Owner::select('id','name')->get();
+        return view('inventory.stockInventory.mission',compact('owners','inventoryAccounts','paginateParams'));
+    }
+    //进入盘点中或复盘页面
+    public function enterStockInventory($id){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
+        $inventoryAccount=InventoryAccount::with('owner')->find($id);
+        $inventoryAccountMissions=InventoryAccountMission::with(['commodity'=>function($query){
+           return $query->with(['barcodes']);
+        }])->where('inventory_account_id',$id)->orderBy('difference_amount','desc')->get();
+        return view('inventory.stockInventory.inventoryMission',compact('inventoryAccount','inventoryAccountMissions'));
+    }
+
+
+
+    //依据盘点任务id进行 --盘点
+    public function stockInventory(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        $location=$request->input('location');
+        $barcode=$request->input('barcode');
+        $inventoryId=$request->input('inventoryId');
+        $count=$request->input('count');
+        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
+        $inventoryAccountMission=app('inventoryService')->stockInventory($location,$barcode,$count,$inventoryId);
+        if (!$inventoryAccountMission)return ['success'=>false,'data'=>'参数错误!'];
+        $inventoryAccount=app('inventoryService')->updateInventory($inventoryId);
+        return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount];
+    }
+    //根据该库存和产品条码查询该条盘点记录
+    public function searchStockInventoryRecord(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        $location=$request->input('location');
+        $barcode=$request->input('barcode');
+        $inventoryId=$request->input('inventoryId');
+        $inventoryAccountMission=app('inventoryService')->searchStockInventoryRecord($location,$barcode,$inventoryId);
+        if (!$inventoryAccountMission)return ['success'=>false,'data'=>'参数错误!'];
+        return ['success'=>true,'data'=>$inventoryAccountMission];
+    }
+
+    //盘点任务导出
+    public function stockInventoryExport(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        ini_set('max_execution_time',3500);
+        ini_set('memory_limit','3526M');
+        if ($request->checkAllSign){
+            $request->offsetUnset('checkAllSign');
+            $queryParam=$request->all();
+            $inventoryAccounts=app('inventoryService')->get($queryParam);
+        }else{
+            $queryParam=$request->all();
+            $inventoryAccounts=app('inventoryService')->some($queryParam);
+        }
+        $row=[[
+            'id'=>'盘点编号',
+            'created_at'=>'创建时间',
+            'owner_id'=>'货主',
+            'type'=>'任务类型',
+            'start_at'=>'起始时间',
+            'end_at'=>'结束时间',
+            'total'=>'记录数',
+            'processed'=>'已盘数',
+            'surplus'=>'剩余数',
+            'difference'=>'复盘差异',
+            'returned'=>'复盘归位',
+        ]];
+        $list=[];
+        for ($i=0; $i<count($inventoryAccounts);$i++){
+            $inventoryAccount=$inventoryAccounts[$i];
+            $w=[
+                'id'=>isset($inventoryAccount->id)?$inventoryAccount->id:'',
+                'created_at'=>isset($inventoryAccount->created_at)?$inventoryAccount->created_at:'',
+                'owner_id'=>isset($inventoryAccount->owner->name)?$inventoryAccount->owner->name:'',
+                'type'=>isset($inventoryAccount->type)?$inventoryAccount->type:'',
+                'start_at'=>isset($inventoryAccount->start_at)?$inventoryAccount->start_at:'',
+                'end_at'=>isset($inventoryAccount->end_at)?$inventoryAccount->end_at:'',
+                'total'=>isset($inventoryAccount->total)?$inventoryAccount->total:'',
+                'processed'=>isset($inventoryAccount->processed)?$inventoryAccount->processed:'',
+                'surplus'=>isset($inventoryAccount->surplus)?$inventoryAccount->surplus:'',
+                'difference'=>isset($inventoryAccount->difference)?$inventoryAccount->difference:'',
+                'returned'=>isset($inventoryAccount->returned)?$inventoryAccount->returned:'',
+            ];
+            $list[$i]=$w;
+        }
+        return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
+    }
+}

+ 58 - 126
app/Http/Controllers/InventoryController.php

@@ -3,11 +3,8 @@
 namespace App\Http\Controllers;
 
 use App\Exports\Export;
-use App\Inventory;
-use App\InventoryMission;
 use App\OracleBasCustomer;
-use App\Owner;
-use App\Services\InventoryService;
+use App\Services\InventoryAccountService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
@@ -17,8 +14,9 @@ class InventoryController extends Controller
 {
     public function __construct()
     {
-        app()->singleton('inventoryService',InventoryService::class);
+        app()->singleton('inventoryService',InventoryAccountService::class);
     }
+    //动库表表
     private function conditionQuery(Request $request,$page=null,$paginate=null){
         $date_start=$request->input('date_start');
         $range = $request->input('range');
@@ -90,7 +88,54 @@ class InventoryController extends Controller
         if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
         $sql.=' )  ';
         if ($page&&$paginate)$sql.="  where rn>'".($page-1)*$paginate."'";
-        //dd($sql);
+        return DB::connection('oracle')->select($sql);
+    }
+    //全部库存
+    private function conditionQueryAllInventory(Request $request,$page=null,$paginate=null){
+        $date_start=$request->date_start;
+        $range = $request->range;
+        if ($range)$date_start=date('Y-m-d',strtotime('-'.$range." day"));
+        $date_end=$request->date_end;
+        $TOLocation=$request->TOLocation;
+        $LotAtt05=$request->LotAtt05;
+        $LotAtt02_start=$request->LotAtt02_start;
+        $descr_c=$request->descr_c;
+        $SKU=$request->SKU;
+        $ALTERNATE_SKU1=$request->ALTERNATE_SKU1;
+        $LotAtt02_end=$request->LotAtt02_end;
+        $sql='select * from (select result.*,rownum rn from (';
+        $sql.=' select customer.Descr_C as 货主,storeStatus.CUSTOMERID 客户,storeStatus.LocationID 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
+        $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, storeStatus.ADDTIME 创建时间, ';
+        $sql.=' lot.LotAtt04 批号 ';
+        $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
+        $sql.=' INV_LOT_LOC_ID storeStatus';
+        $sql.=' left join BAS_Customer customer on customer.CustomerID=storeStatus.CUSTOMERID ';
+        $sql.=' left join BAS_SKU sku on sku.SKU=storeStatus.SKU and sku.CUSTOMERID=storeStatus.CUSTOMERID ';
+        $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM = storeStatus.LOTNUM AND lot.CUSTOMERID = storeStatus.CUSTOMERID ';
+        $sql.=' group by storeStatus.LocationID,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
+        $sql.=' ,sku.Descr_C,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
+        $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,storeStatus.CUSTOMERID,storeStatus.ADDTIME  ';
+        $sql.=' )result where 1=1 ';
+        if ($TOLocation)$sql .= " and 库位 like '".$TOLocation."' ";
+        if ($SKU)$sql.=" and 产品编码 like '".$SKU."' ";
+        if ($LotAtt05)$sql .=" and 属性仓 like '".$LotAtt05."' ";
+        if ($date_start)$sql.=" and 创建时间 > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
+        if ($date_end)$sql.=" and 创建时间 < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
+        if ($LotAtt02_start)$sql.=" and 失效日期 >='".$LotAtt02_start." 00:00:00' ";
+        if ($LotAtt02_end)$sql.=" and 失效日期 <='".$LotAtt02_end." 23:59:59' ";
+        if ($descr_c){
+            $sql .= ' and 货主 in (';
+            $descr_cs = explode(',',$descr_c);
+            foreach ($descr_cs as $index => $descr_c){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$descr_c."'";
+            }
+            $sql .= ') ';
+        }
+        if ($ALTERNATE_SKU1)$sql.=" and 产品条码 like '".$ALTERNATE_SKU1."' ";
+        if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
+        $sql.=' )  ';
+        if ($page&&$paginate)$sql.="  where rn>'".($page-1)*$paginate."'";
         return DB::connection('oracle')->select($sql);
     }
     //动库报表
@@ -101,17 +146,19 @@ class InventoryController extends Controller
         $oracleActTransactingLogs=$this->conditionQuery($request,$page,$paginate);
         $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
         $owners=OracleBasCustomer::select('descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
-        return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners'));
+        $isTotalStock=false;
+        return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners','isTotalStock'));
     }
     //全部库存
     public function allInventory(Request $request){
         if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
         $page=$request->page??1;
         $paginate=$request->input('paginate')??50;
-        $oracleActTransactingLogs=$this->conditionQuery($request,$page,$paginate);
+        $oracleActTransactingLogs=$this->conditionQueryAllInventory($request,$page,$paginate);
         $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
         $owners=OracleBasCustomer::select('descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
-        return view('inventory.statement.allInventory',compact('oracleActTransactingLogs','page','owners'));
+        $isTotalStock=true;
+        return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners','isTotalStock'));
     }
     public function exportData(Request $request){
         if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
@@ -153,8 +200,8 @@ class InventoryController extends Controller
                 'sku_Descr_C'=>$oracleActTransactingLogs[$i]['商品名称'],
                 'LotAtt08'=>$oracleActTransactingLogs[$i]['质量状态'],
                 'LotAtt04'=>$oracleActTransactingLogs[$i]['批号'],
-                'come_sum'=>$oracleActTransactingLogs[$i]['移出数量'],
-                'join_sum'=>$oracleActTransactingLogs[$i]['移入数量'],
+                'come_sum'=>isset($oracleActTransactingLogs[$i]['移出数量'])?$oracleActTransactingLogs[$i]['移出数量']:'',
+                'join_sum'=>isset($oracleActTransactingLogs[$i]['移入数量'])?$oracleActTransactingLogs[$i]['移入数量']:'',
                 'QTY'=>$oracleActTransactingLogs[$i]['在库数量'],
                 'QtyAllocated'=>$oracleActTransactingLogs[$i]['占用数量'],
             ];
@@ -162,119 +209,4 @@ class InventoryController extends Controller
         }
         return Excel::download(new Export($row,$list),date('YmdHis', time()).'-动库报表单.xlsx');
     }
-
-
-
-
-
-    //创建盘点任务
-    public function createStockInventoryMission(Request $request){
-        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
-        $date_start=$request->input('formData.date_start');
-        $date_end=$request->input('formData.date_end');
-        $ownerId=$request->input('formData.owner_id')[0];
-        $inventory=app('inventoryService')->createMission($date_start,$date_end,$ownerId);
-        $inventory=Inventory::with('owner')->find($inventory->id);
-        if (is_null($inventory)) return ['success'=>false,'data'=>'参数错误!'];
-        return ['success'=>true,'data'=>$inventory];
-    }
-    //删除盘点任务
-    public function deleteStockInventoryMission($id){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>0,'status'=>'没有权限'];}
-        if(is_null($id)){return ['success'=>false,'data'=>'传入id为空'];}
-        $inventory=Inventory::where('id',$id)->delete();
-        return ['success'=>true,'data'=>$inventory];
-    }
-    //盘点-任务页面
-    public function mission(Request $request){
-        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
-        $paginateParams = $request->input();
-        $queryParam=$request->all();
-        $inventories=app('inventoryService')->paginate($queryParam);
-        $owners=Owner::select('id','name')->get();
-        return view('inventory.stockInventory.mission',compact('owners','inventories','paginateParams'));
-    }
-    //进入盘点中或复盘页面
-    public function enterStockInventory($id){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
-        $inventory=Inventory::with('owner')->find($id);
-        $inventoryMissions=InventoryMission::with(['commodity'=>function($query){
-           return $query->with(['barcodes']);
-        }])->where('inventory_id',$id)->orderBy('difference_amount','desc')->get();
-//        ->whereHas('commodity',function ($query)use($inventory){
-//            return $query->where('owner_id',$inventory->owner_id);
-//        })
-        return view('inventory.stockInventory.inventoryMission',compact('inventory','inventoryMissions'));
-    }
-    //依据盘点任务id进行 --盘点
-    public function stockInventory(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $location=$request->input('location');
-        $barcode=$request->input('barcode');
-        $inventoryId=$request->input('inventoryId');
-        $count=$request->input('count');
-        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
-        $inventoryMission=app('inventoryService')->stockInventory($location,$barcode,$count,$inventoryId);
-        if (!$inventoryMission)return ['success'=>false,'data'=>'参数错误!'];
-        $inventory=app('inventoryService')->updateInventory($inventoryId);
-        return ['success'=>true,'inventoryMission'=>$inventoryMission,'inventory'=>$inventory];
-    }
-    //根据该库存和产品条码查询该条盘点记录
-    public function searchStockInventoryRecord(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $location=$request->input('location');
-        $barcode=$request->input('barcode');
-        $inventoryId=$request->input('inventoryId');
-        $inventoryMission=app('inventoryService')->searchStockInventoryRecord($location,$barcode,$inventoryId);
-        if (!$inventoryMission)return ['success'=>false,'data'=>'参数错误!'];
-        return ['success'=>true,'data'=>$inventoryMission];
-    }
-
-    //盘点任务导出
-    public function stockInventoryExport(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        ini_set('max_execution_time',3500);
-        ini_set('memory_limit','3526M');
-        if ($request->checkAllSign){
-            $request->offsetUnset('checkAllSign');
-            $queryParam=$request->all();
-            $inventories=app('inventoryService')->get($queryParam);
-        }else{
-            $queryParam=$request->all();
-            $inventories=app('inventoryService')->some($queryParam);
-        }
-        $row=[[
-            'id'=>'盘点编号',
-            'created_at'=>'创建时间',
-            'owner_id'=>'货主',
-            'type'=>'任务类型',
-            'start_at'=>'起始时间',
-            'end_at'=>'结束时间',
-            'total'=>'记录数',
-            'processed'=>'已盘数',
-            'surplus'=>'剩余数',
-            'difference'=>'复盘差异',
-            'returned'=>'复盘归位',
-        ]];
-        $list=[];
-        for ($i=0; $i<count($inventories);$i++){
-            $inventory=$inventories[$i];
-            $w=[
-                'id'=>isset($inventory->id)?$inventory->id:'',
-                'created_at'=>isset($inventory->created_at)?$inventory->created_at:'',
-                'owner_id'=>isset($inventory->owner->name)?$inventory->owner->name:'',
-                'type'=>isset($inventory->type)?$inventory->type:'',
-                'start_at'=>isset($inventory->start_at)?$inventory->start_at:'',
-                'end_at'=>isset($inventory->end_at)?$inventory->end_at:'',
-                'total'=>isset($inventory->total)?$inventory->total:'',
-                'processed'=>isset($inventory->processed)?$inventory->processed:'',
-                'surplus'=>isset($inventory->surplus)?$inventory->surplus:'',
-                'difference'=>isset($inventory->difference)?$inventory->difference:'',
-                'returned'=>isset($inventory->returned)?$inventory->returned:'',
-            ];
-            $list[$i]=$w;
-        }
-        return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
-    }
 }

+ 9 - 9
app/Http/Controllers/InventoryMissionController.php

@@ -2,7 +2,7 @@
 
 namespace App\Http\Controllers;
 
-use App\InventoryMission;
+use App\InventoryAccountMission;
 use Illuminate\Http\Request;
 
 class InventoryMissionController extends Controller
@@ -41,10 +41,10 @@ class InventoryMissionController extends Controller
     /**
      * Display the specified resource.
      *
-     * @param  \App\InventoryMission  $inventoryMission
+     * @param  \App\InventoryAccountMission  $inventoryMission
      * @return \Illuminate\Http\Response
      */
-    public function show(InventoryMission $inventoryMission)
+    public function show(InventoryAccountMission $inventoryMission)
     {
         //
     }
@@ -52,10 +52,10 @@ class InventoryMissionController extends Controller
     /**
      * Show the form for editing the specified resource.
      *
-     * @param  \App\InventoryMission  $inventoryMission
+     * @param  \App\InventoryAccountMission  $inventoryMission
      * @return \Illuminate\Http\Response
      */
-    public function edit(InventoryMission $inventoryMission)
+    public function edit(InventoryAccountMission $inventoryMission)
     {
         //
     }
@@ -64,10 +64,10 @@ class InventoryMissionController extends Controller
      * Update the specified resource in storage.
      *
      * @param  \Illuminate\Http\Request  $request
-     * @param  \App\InventoryMission  $inventoryMission
+     * @param  \App\InventoryAccountMission  $inventoryMission
      * @return \Illuminate\Http\Response
      */
-    public function update(Request $request, InventoryMission $inventoryMission)
+    public function update(Request $request, InventoryAccountMission $inventoryMission)
     {
         //
     }
@@ -75,10 +75,10 @@ class InventoryMissionController extends Controller
     /**
      * Remove the specified resource from storage.
      *
-     * @param  \App\InventoryMission  $inventoryMission
+     * @param  \App\InventoryAccountMission  $inventoryMission
      * @return \Illuminate\Http\Response
      */
-    public function destroy(InventoryMission $inventoryMission)
+    public function destroy(InventoryAccountMission $inventoryMission)
     {
         //
     }

+ 6 - 6
app/Inventory.php → app/InventoryAccount.php

@@ -6,7 +6,7 @@ use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
 
-class Inventory extends Model
+class InventoryAccount extends Model
 {
     use ModelTimeFormat;
     use SoftDeletes;
@@ -20,7 +20,7 @@ class Inventory extends Model
         return $this->belongsTo('App\Owner','owner_id','id');
     }
     public function inventoryMissions(){
-        return $this->belongsTo('App\InventoryMission','id','inventory_id');
+        return $this->belongsTo('App\InventoryAccountMission','id','inventory_account_id');
     }
 
     public function getSurplusAttribute()
@@ -28,19 +28,19 @@ class Inventory extends Model
         return $this['total'] ? $this['total']-$this['processed']:0;
     }
     public function getProcessedAmount(){
-        return $this->inventoryMissions()->where('checked','是')->where('inventory_id',$this['id'])->count();
+        return $this->inventoryMissions()->where('checked','是')->where('inventory_account_id',$this['id'])->count();
     }
     //复盘剩余数
     public function getCheckSurplusAttribute()
     {
-        $re_checked_amount=$this->inventoryMissions()->where('inventory_id',$this['id'])->whereNotNull('re_checked_amount')->count();
+        $re_checked_amount=$this->inventoryMissions()->where('inventory_account_id',$this['id'])->whereNotNull('re_checked_amount')->count();
         return $this['total'] ? $this['total']-$re_checked_amount:null;
     }
     public function getDifferenceAmount(){
-        return $this->inventoryMissions()->where('inventory_id',$this['id'])->where('difference_amount','>',0)->count();
+        return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('difference_amount','>',0)->count();
     }
     public function getReturnedAmount(){
-        return $this->inventoryMissions()->where('inventory_id',$this['id'])->where('returned','是')->count();
+        return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('returned','是')->count();
 
     }
 }

+ 2 - 2
app/InventoryMission.php → app/InventoryAccountMission.php

@@ -4,10 +4,10 @@ namespace App;
 
 use Illuminate\Database\Eloquent\Model;
 
-class InventoryMission extends Model
+class InventoryAccountMission extends Model
 {
     protected $fillable=[
-        'id','inventory_id','location','commodity_id', 'produced_at', 'valid_at','stored_at','batch_number','erp_type_position','quality','stored_amount','valid_amount',
+        'id','inventory_account_id','location','commodity_id', 'produced_at', 'valid_at','stored_at','batch_number','erp_type_position','quality','stored_amount','valid_amount',
         'verified_amount','re_checked_amount','difference_amount','occupied_amount','checked',
     ];
     public function commodity(){

+ 81 - 64
app/Services/InventoryService.php → app/Services/InventoryAccountService.php

@@ -5,10 +5,11 @@ namespace App\Services;
 
 use App\Commodity;
 use App\Http\Controllers\Controller;
-use App\Inventory;
-use App\InventoryMission;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\OraccleBasCustomer;
 use App\OracleActTransactionLog;
+use App\OracleInvLotLocId;
 use App\Owner;
 use App\Services\common\QueryService;
 use Illuminate\Http\Request;
@@ -17,11 +18,11 @@ use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
 
-class InventoryService
+class InventoryAccountService
 {
 
     private function conditionQuery($queryParam){
-        $inventories=Inventory::query()->with(['owner'])->orderBy('id','desc');
+        $inventories=InventoryAccount::query()->with(['owner'])->orderBy('id','desc');
         $columnQueryRules=[
             'owner_id' => ['multi' => ','],
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
@@ -41,11 +42,11 @@ class InventoryService
     }
 
     public function some($queryParam){
-        return Inventory::query()->with(['owner'])->orderBy('id','DESC')
+        return InventoryAccount::query()->with(['owner'])->orderBy('id','DESC')
             ->whereIn('id',explode(',',$queryParam['data']))->get();
     }
-
-    public function conditionSearch($date_start,$date_end,$ownerId){
+    //动盘查询
+    public function conditionPortStock($date_start,$date_end,$ownerId){
         if (!$ownerId) return null;
         $descr_c=Owner::where('id',$ownerId)->value('name');
         $sql='select * from (select result.*,rownum rn from (';
@@ -93,7 +94,26 @@ class InventoryService
             $sql .= ') ';
         }
         $sql.=' )  ';
-        //dd($sql);
+        return DB::connection('oracle')->select($sql);
+    }
+    //全盘查询
+    private function conditionTotalStock($ownerId){
+        $descr_c=Owner::where('id',$ownerId)->value('name');
+        $sql='select * from (select result.*,rownum rn from (';
+        $sql.=' select customer.Descr_C as 货主,storeStatus.CUSTOMERID 客户,storeStatus.LocationID 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
+        $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, storeStatus.ADDTIME 创建时间, ';
+        $sql.=' lot.LotAtt04 批号,lot.LotAtt01 生产日期,lot.LotAtt03 入库日期 ';
+        $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
+        $sql.=' INV_LOT_LOC_ID storeStatus';
+        $sql.=' left join BAS_Customer customer on customer.CustomerID=storeStatus.CUSTOMERID ';
+        $sql.=' left join BAS_SKU sku on sku.SKU=storeStatus.SKU and sku.CUSTOMERID=storeStatus.CUSTOMERID ';
+        $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM = storeStatus.LOTNUM AND lot.CUSTOMERID = storeStatus.CUSTOMERID ';
+        $sql.=' group by storeStatus.LocationID,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
+        $sql.=' ,sku.Descr_C,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
+        $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,storeStatus.CUSTOMERID,storeStatus.ADDTIME,lot.LotAtt01,lot.LotAtt03  ';
+        $sql.=' )result where 1=1 ';
+        if ($descr_c)$sql.=" and 货主 = '".$descr_c."' ";
+        $sql.=' )  ';
         return DB::connection('oracle')->select($sql);
     }
     //创建盘点任务
@@ -102,41 +122,39 @@ class InventoryService
         if ($date_start&&$date_end){
             $date_end_time=$date_end.' 23:59:59';
             $type='动盘';
+            $wmsInventories=$this->conditionPortStock($date_start,$date_end,$ownerId);
         }elseif (!$date_start&&!$date_end){
             $name=Owner::where('id',$ownerId)->value('name');
             $ownerName=OraccleBasCustomer::where('customer_type','OW')->where('active_flag','Y')->where('descr_c',$name)->value('customerid');
-            $date_start=OracleActTransactionLog::where('fmcustomerid',$ownerName)->orderBy('addtime','asc')->value('addtime');
-            $date_end_time=OracleActTransactionLog::where('fmcustomerid',$ownerName)->orderBy('addtime','desc')->value('addtime');
+            $date_start=OracleInvLotLocId::where('customerid',$ownerName)->orderBy('addtime','ASC')->value('addtime');
+            $date_end_time=OracleInvLotLocId::where('customerid',$ownerName)->orderBy('addtime','DESC')->value('addtime');
             $type='全盘';
+            $wmsInventories=$this->conditionTotalStock($ownerId);
         }else{
             return null;
         }
-        $inventory=new Inventory([
+        $inventory=new InventoryAccount([
             'owner_id'=>$ownerId,
             'type'=>$type,
             'start_at'=>$date_start,
             'end_at'=>$date_end_time,
+            'total'=>count($wmsInventories),
         ]);
         $inventory->save();
-        $this->createInventoryMissionRecord($date_start,$date_end,$ownerId,$inventory['id']);
+        $this->createInventoryAccountMissionRecord($ownerId,$inventory['id'],$wmsInventories);
         $request=[
             'date_start'=>$date_start,
             'date_end'=>$date_end,
             'ownerId'=>$ownerId,
             'inventoryId'=>$inventory['id'],
         ];
-        Controller::logS(__METHOD__,"创建盘点记录任务__".__FUNCTION__,json_encode($request),Auth::user()['id']);
-        $inventoryMissionCount=InventoryMission::where('inventory_id',$inventory['id'])->count();
-        $inventory->total=$inventoryMissionCount;
-        $inventory->update();
         Controller::logS(__METHOD__,"创建盘点任务__".__FUNCTION__,json_encode($request),Auth::user()['id']);
         return $inventory;
     }
 
     //创建盘点记录任务
-    public function createInventoryMissionRecord($date_start,$date_end,$ownerId,$inventoryId){
-        if (!$ownerId) return null;
-        $wmsInventories=$this->conditionSearch($date_start,$date_end,$ownerId);
+    public function createInventoryAccountMissionRecord($ownerId,$inventoryAccountId,$wmsInventories){
+        $inventoryAccountMissions=[];
         foreach ($wmsInventories as $wmsInventory){
             $commodity=Commodity::query()->firstOrCreate([
                 'owner_id'=>$ownerId,
@@ -146,75 +164,74 @@ class InventoryService
             Controller::logS(__METHOD__,"根据wms产品编码和货主查询或创建商品信息__".__FUNCTION__,json_encode($wmsInventory));
             $commodity->newBarcode($wmsInventory->产品条码);
             Controller::logS(__METHOD__,"根据wms产品条码和商品id查询或创建商品条码信息__".__FUNCTION__,json_encode($wmsInventory));
-            $inventoryMission = new InventoryMission();
-            $inventoryMission->commodity_id=$commodity->id;
-            $inventoryMission->inventory_id=$inventoryId;
-            $inventoryMission->location=$wmsInventory->库位;
-            $inventoryMission->produced_at=$wmsInventory->生产日期;
-            $inventoryMission->valid_at=$wmsInventory->失效日期;
-            $inventoryMission->stored_at=$wmsInventory->入库日期;
-            $inventoryMission->batch_number=$wmsInventory->批号;
-            $inventoryMission->erp_type_position=$wmsInventory->属性仓;
-            $inventoryMission->quality=$wmsInventory->质量状态;
-            $inventoryMission->stored_amount=$wmsInventory->在库数量;
-            $inventoryMission->occupied_amount=$wmsInventory->占用数量;
-            $inventoryMission->save();
+            $inventoryAccountMission=[
+            'commodity_id'=>$commodity->id,
+            'inventory_account_id'=>$inventoryAccountId,
+            'location'=>$wmsInventory->库位,
+            'produced_at'=>$wmsInventory->生产日期,
+            'valid_at'=>$wmsInventory->失效日期,
+            'stored_at'=>$wmsInventory->入库日期,
+            'batch_number'=>$wmsInventory->批号,
+            'erp_type_position'=>$wmsInventory->属性仓,
+            'quality'=>$wmsInventory->质量状态,
+            'stored_amount'=>$wmsInventory->在库数量,
+            'occupied_amount'=>$wmsInventory->占用数量,
+            ];
+            array_push($inventoryAccountMissions,$inventoryAccountMission);
         }
-
+        DB::table('inventory_account_missions')->insert($inventoryAccountMissions);
     }
     //盘点库存
-    public function stockInventory($location,$barcode,$count,$inventoryId){
+    public function stockInventory($location,$barcode,$count,$inventoryAccountId){
 
-        $inventoryMission=InventoryMission::whereHas('commodity',function($query)use($barcode){
+        $inventoryAccountMission=InventoryAccountMission::whereHas('commodity',function($query)use($barcode){
              $query->whereHas('barcodes',function($sql)use($barcode){
                  $sql->where('code','=',$barcode);
             });
-        })->where('location',$location)->where('inventory_id',$inventoryId)->first();
-        if (!$inventoryMission) return null;
-        $inventory=Inventory::find($inventoryId);
+        })->where('location',$location)->where('inventory_account_id',$inventoryAccountId)->first();
+        if (!$inventoryAccountMission) return null;
+        $inventory=InventoryAccount::find($inventoryAccountId);
         if ($inventory->surplus!=0){
-            $inventoryMission->verified_amount=$count;
-            $inventoryMission->difference_amount=abs($inventoryMission->stored_amount-$count);
-            $inventoryMission->checked='是';
+            $inventoryAccountMission->verified_amount=$count;
+            $inventoryAccountMission->difference_amount=abs($inventoryAccountMission->stored_amount-$count);
+            $inventoryAccountMission->checked='是';
         }else{
-            $inventoryMission->re_checked_amount=$count;
-            $inventoryMission->difference_amount=abs($inventoryMission->stored_amount-$count);
-            if ($inventoryMission->difference_amount==0){
-                $inventoryMission->returned='是';
+            $inventoryAccountMission->re_checked_amount=$count;
+            $inventoryAccountMission->difference_amount=abs($inventoryAccountMission->stored_amount-$count);
+            if ($inventoryAccountMission->difference_amount==0){
+                $inventoryAccountMission->returned='是';
             }else{
-                $inventoryMission->returned='否';
+                $inventoryAccountMission->returned='否';
             }
         }
-        $inventoryMission->update();
+        $inventoryAccountMission->update();
         $request=[
             'location'=>$location,
             'barcode'=>$barcode,
             'count'=>$count,
-            'inventoryId'=>$inventoryId,
+            'inventoryId'=>$inventoryAccountId,
         ];
         Controller::logS(__METHOD__,"盘点__".__FUNCTION__,json_encode($request));
-        return $inventoryMission;
+        return $inventoryAccountMission;
     }
     //盘点修改盘点任务数据
-    public function updateInventory($inventoryId){
-        $inventory=Inventory::find($inventoryId);
-        $inventory->processed=$inventory->getProcessedAmount();
-        $inventory->difference=$inventory->getDifferenceAmount();
-        $inventory->returned=$inventory->getReturnedAmount();
-        $inventory->update();
-        Controller::logS(__METHOD__,"盘点修改盘点任务中的已盘条数__".__FUNCTION__,json_encode($inventoryId));
-        return $inventory;
+    public function updateInventory($inventoryAccountId){
+        $inventoryAccount=InventoryAccount::find($inventoryAccountId);
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount();
+        $inventoryAccount->update();
+        Controller::logS(__METHOD__,"盘点修改盘点任务中的已盘条数__".__FUNCTION__,json_encode($inventoryAccountId));
+        return $inventoryAccount;
     }
     //根据该库存和产品条码查询该条盘点记录
-    public function searchStockInventoryRecord($location,$barcode,$inventoryId){
-        $inventoryMission=InventoryMission::whereHas('commodity',function($query)use($barcode){
+    public function searchStockInventoryRecord($location,$barcode,$inventoryAccountId){
+        $inventoryAccountMission=InventoryAccountMission::whereHas('commodity',function($query)use($barcode){
             $query->whereHas('barcodes',function($sql)use($barcode){
                 $sql->where('code',$barcode);
             });
-        })->where('location',$location)->where('inventory_id',$inventoryId)->first();
-        if (!$inventoryMission) return null;
-        return  $inventoryMission;
+        })->where('location',$location)->where('inventory_account_id',$inventoryAccountId)->first();
+        if (!$inventoryAccountMission) return null;
+        return  $inventoryAccountMission;
     }
-
-
 }

+ 2 - 2
database/factories/InventoryFactory.php

@@ -2,11 +2,11 @@
 
 /** @var \Illuminate\Database\Eloquent\Factory $factory */
 
-use App\Inventory;
+use App\InventoryAccount;
 use App\Owner;
 use Faker\Generator as Faker;
 
-$factory->define(Inventory::class, function (Faker $faker) {
+$factory->define(InventoryAccount::class, function (Faker $faker) {
     $owners=Owner::select('id')->get();
     return [
         'owner_id'=>$owners[1],

+ 3 - 3
database/factories/InventoryMissionFactory.php

@@ -2,15 +2,15 @@
 
 /** @var \Illuminate\Database\Eloquent\Factory $factory */
 
-use App\InventoryMission;
+use App\InventoryAccountMission;
 use App\Commodity;
 use Faker\Generator as Faker;
 use Illuminate\Support\Str;
 
-$factory->define(InventoryMission::class, function (Faker $faker) {
+$factory->define(InventoryAccountMission::class, function (Faker $faker) {
     $commoditys=Commodity::get();
     return [
-        'inventory_id'=>'',
+        'inventory_account_id'=>'',
         'location'=>Str::random(5),
         'commodity_id'=>$commoditys[0]['id'],
         'produced_at'=>'',

+ 49 - 0
database/migrations/2020_08_26_093946_change_inventory_missions_to_inventory_account_missions.php

@@ -0,0 +1,49 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeInventoryMissionsToInventoryAccountMissions extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::dropIfExists('inventory_missions');
+        Schema::create('inventory_account_missions', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('inventory_account_id')->index();
+            $table->string('location')->index()->comment('库位');
+            $table->integer('commodity_id')->index()->comment('商品id');
+            $table->timestamp('produced_at')->nullable()->comment('生产日期');
+            $table->timestamp('valid_at')->nullable()->comment('失效日期');
+            $table->timestamp('stored_at')->nullable()->comment('入库日期');
+            $table->string('batch_number')->nullable()->comment('批号');
+            $table->string('erp_type_position')->nullable()->comment('erp属性仓');
+            $table->string('quality')->nullable()->comment('质量状态');
+            $table->integer('stored_amount')->nullable()->comment('库存数量');
+            $table->integer('valid_amount')->default(0)->comment('可用数量');
+            $table->integer('verified_amount')->nullable()->comment('盘点数量');
+            $table->integer('re_checked_amount')->nullable()->comment('复盘数量');
+            $table->integer('difference_amount')->nullable()->comment('盘点差异');
+            $table->integer('occupied_amount')->nullable()->comment('分配数量');
+            $table->enum('checked',['是','否'])->default('否')->comment('已盘点');
+            $table->enum('returned',['是','否','无'])->default('无')->comment('已归位');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventory_account_missions');
+    }
+}

+ 41 - 0
database/migrations/2020_08_26_094015_change_inventories_to_inventory_accounts.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeInventoriesToInventoryAccounts extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::dropIfExists('inventories');
+        Schema::create('inventory_accounts', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('owner_id')->index();
+            $table->enum('type',['全盘','动盘'])->comment('盘点类型');
+            $table->timestamp('start_at')->nullable();
+            $table->timestamp('end_at')->nullable();
+            $table->integer('total')->nullable()->comment('记录数');
+            $table->integer('processed')->default(0)->comment('已盘数');
+            $table->integer('difference')->default(0)->comment('复盘差异');
+            $table->integer('returned')->default(0)->comment('复盘归位');
+            $table->timestamp('deleted_at')->index()->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventory_accounts');
+    }
+}

+ 2 - 2
public/js/app.js

@@ -61974,8 +61974,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\Reald\desktop\BsWAS\src\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\Reald\desktop\BsWAS\src\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\wamp64\www\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),

+ 0 - 199
resources/views/inventory/statement/allInventory.blade.php

@@ -1,199 +0,0 @@
-@extends('layouts.app')
-@section('title')库存管理-全部库存@endsection
-@section('content')
-    @component('inventory.statement.menu')@endcomponent
-<div id="list" class="d-none card container-fluid" style="min-width: 1500px">
-    <div id="form_div"></div>
-    <span class="dropdown">
-        <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="processExport(false)" href="javascript:">导出勾选内容</a>
-            <a class="dropdown-item" @click="processExport(true)" href="javascript:">导出所有页</a>
-        </div>
-    </span>
-    <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
-        <tr>
-            <th>
-                <label for="all">
-                    <input id="all" type="checkbox" @click="checkAll($event)">全选
-                </label>
-            </th>
-            <th>序号</th>
-            <th>货主</th>
-            <th>库位</th>
-            <th>产品编码</th>
-            <th>产品条码</th>
-            <th>商品名称</th>
-            <th>属性仓</th>
-            <th>质量状态</th>
-            <th>失效日期</th>
-            <th>批号</th>
-            <th>在库数量</th>
-            <th>占用数量</th>
-        </tr>
-        <tr v-for="(oracleActTransactingLog,i) in oracleActTransactingLogs">
-            <td>
-                <input class="checkItem" type="checkbox" :value="oracleActTransactingLog" v-model="checkData">
-            </td>
-            <td>@{{ i+1 }}</td>
-            <td class="text-primary">@{{ oracleActTransactingLog.货主 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.库位 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.产品编码 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.产品条码 }}</td>
-            <td :title="oracleActTransactingLog.商品名称" class="tooltipTarget" style="max-width: 200px;overflow:hidden">@{{ oracleActTransactingLog.商品名称 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.属性仓 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.质量状态 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.失效日期 }}</td>
-            <td class="text-muted">@{{ oracleActTransactingLog.批号 }}</td>
-            <td><span v-if="oracleActTransactingLog.在库数量">@{{ oracleActTransactingLog.在库数量 }}</span><span v-else>0</span></td>
-            <td><span v-if="oracleActTransactingLog.占用数量">@{{ oracleActTransactingLog.占用数量 }}</span><span v-else>0</span></td>
-        </tr>
-    </table>
-    <div>
-        <button type="button" @click="pageUp()" :readonly="page>1?false:true" class="btn btn-sm " :class="page>1?'btn-outline-info':''">上一页</button>
-        <button type="button" @click="pageDown()" :readonly="page<maxPage?false:true" class="btn btn-sm m-3" :class="page<maxPage?'btn-outline-info':''">下一页</button>
-        <div v-if="isPage">
-            <input  @keyup.enter="pageSkip($event)" class="form-control-sm ml-3 tooltipTarget" :placeholder="'当前页数:'+page+'/'+maxPage" title="去往指定页">
-            <span class="text-muted m-1">共 @{{ sum }} 条</span>
-        </div>
-    </div>
-</div>
-@endsection
-
-@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>
-        $.cookie('xxx', 2223);
-        new Vue({
-            el:"#list",
-            data:{
-                oracleActTransactingLogs:{!! $oracleActTransactingLogs !!},
-                page:Number('{{$page}}'),
-                owners:[
-                    @foreach($owners as $owner)
-                    {name:'{{$owner->descr_c}}',value:'{{$owner->descr_c}}'},
-                    @endforeach
-                ],
-                checkData:[],
-                maxPage:1,
-                sum:0,
-                isPage:true,
-                date:[{name:'1',value:'近一天'},{name:'3',value:'近三天'},{name:'7',value:'近一周'},{name:'30',value:'近一月'},],
-            },
-            mounted:function () {
-                $(".tooltipTarget").tooltip({'trigger':'hover'});
-                $("#list").removeClass('d-none');
-                if (this.oracleActTransactingLogs.length>0){
-                    this.maxPage=Math.ceil(this.oracleActTransactingLogs[0].sum/50);
-                    this.sum=this.oracleActTransactingLogs[0].sum;
-                }
-                let data=[
-                    [
-                        {name:['date_start','range'],type:'dateTime_select',tip:['选择创建日期的起始时间','查询内容的日期范围'],placeholder:['','查询内容的日期范围'],data: this.date
-                            ,killings:[['range'],['date_start']]},
-                        {name:'TOLocation',type:'input',tip:'库位:糊模查找需要在左边打上%符号',placeholder: '库位'},
-                        {name:'LotAtt05',type:'input',tip:'属性仓:糊模查找需要在左边打上%符号',placeholder: '属性仓'},
-                        {name:'LotAtt02_start',type:'dateTime',tip:'选择显示失效日期的起始时间'},
-                        {name:'descr_c',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
-                            placeholder:['货主','定位或多选货主'],data:this.owners},
-                    ],
-                    [
-                        {name:'date_end',type:'dateTime',tip:'选择创建日期的结束时间',killings:['range']},
-                        {name:'SKU',type:'input',tip:'产品编码:糊模查找需要在左边打上%符号',placeholder: '产品编码'},
-                        {name:'ALTERNATE_SKU1',type:'input',tip:'产品条码:糊模查找需要在左边打上%符号',placeholder: '产品条码'},
-                        {name:'LotAtt02_end',type:'dateTime',tip:'选择显示失效日期的结束时间'},
-                    ],
-                ];
-                this.form = new query({
-                    el:'#form_div',
-                    condition:data
-                });
-                this.form.init();
-                let thisUrl=document.URL;
-                let parameter=thisUrl.split('?',2);
-                if (parameter.length > 1){
-                    let _this=this;
-                    let list=['ALTERNATE_SKU1','LotAtt05','LotAtt02_start','descr_c','LotAtt02_end'];
-                    let param=parameter[1].split('&');
-                    param.every(function (data) {
-                        let arr=data.split('=');
-                        if (arr.length > 1){
-                            if (list.includes(arr[0]) && arr[1]){
-                                _this.isPage = false;
-                                return false;
-                            }
-                        }
-                        return true;
-                    });
-                }
-            },
-            watch:{
-                checkData:{
-                    handler(){
-                        if (this.checkData.length === this.oracleActTransactingLogs.length){
-                            document.querySelector('#all').checked = true;
-                        }else {
-                            document.querySelector('#all').checked = false;
-                        }
-                    },
-                    deep:true
-                }
-            },
-            methods:{
-                pageUp(){
-                    if (this.page<=1)return;
-                    this.href(this.page-1);
-                },
-                pageDown(){
-                    if (this.page>=this.maxPage)return;
-                    this.href(this.page+1);
-                },
-                pageSkip(e){
-                    if (Number(e.target.value)<=0 || Number(e.target.value)>this.maxPage){
-                        tempTip.setDuration(2000);
-                        tempTip.show('页数不存在! ');
-                        return
-                    }
-                    this.href(e.target.value);
-                },
-                href(page){
-                    let url = document.URL;
-                    if (url.indexOf('page='+this.page) != -1){
-                        url = url.replace("page="+this.page,"page="+page);
-                    }else{
-                        if (url.indexOf('?') == -1) url += "?page="+page;
-                        else url += "&page="+page;
-                    }
-                    window.location.href=url;
-                },
-                //全选事件
-                checkAll(e){
-                    if (e.target.checked){
-                        this.oracleActTransactingLogs.forEach((el,i)=>{
-                            if (this.checkData.indexOf(el) == '-1'){
-                                this.checkData.push(el);
-                            }
-                        });
-                    }else {
-                        this.checkData = [];
-                    }
-                },
-                processExport(checkAllSign){
-                    let url = '{{url('inventory/statement/changeInventory/export')}}';
-                    let token='{{ csrf_token() }}';
-                    let data= JSON.stringify( this.checkData );
-                    excelExport(checkAllSign,data,url,this.sum,token);
-                },
-            },
-            filters:{
-                json(value) {
-                    return JSON.stringify(value);
-                }
-            },
-        });
-    </script>
-@endsection

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

@@ -34,8 +34,10 @@
             <td class="text-muted">@{{ oracleActTransactingLog.质量状态 }}</td>
             <td class="text-muted">@{{ oracleActTransactingLog.失效日期 }}</td>
             <td class="text-muted">@{{ oracleActTransactingLog.批号 }}</td>
+            @if(!$isTotalStock)
             <td>@{{ oracleActTransactingLog.移出数量 }}</td>
             <td>@{{ oracleActTransactingLog.移入数量 }}</td>
+            @endif
             <td><span v-if="oracleActTransactingLog.在库数量">@{{ oracleActTransactingLog.在库数量 }}</span><span v-else>0</span></td>
             <td><span v-if="oracleActTransactingLog.占用数量">@{{ oracleActTransactingLog.占用数量 }}</span><span v-else>0</span></td>
         </tr>
@@ -132,8 +134,10 @@
                     {name:'质量状态',value: '质量状态', class:'text-muted'},
                     {name:'失效日期',value: '失效日期', class:'text-muted'},
                     {name:'批号',value: '批号', class:'text-muted'},
+                    @if(!$isTotalStock)
                     {name:'移出数量',value: '移出数量', neglect: true},
                     {name:'移入数量',value: '移入数量', neglect: true},
+                    @endif
                     {name:'在库数量',value: '在库数量', neglect: true},
                     {name:'占用数量',value: '占用数量', neglect: true},
                 ];

+ 6 - 5
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -1,10 +1,10 @@
 @extends('layouts.app')
-@section('title')盘点-任务-{!! $inventory->id !!}@endsection
+@section('title')盘点-任务-{!! $inventoryAccount->id !!}@endsection
 
 @section('content')
         @component('inventory.stockInventory.menu')
             <li class="nav-item">
-                <a  class="nav-link" href="{{URL::current()}}" :class="{active:isActive('enterStockInventory',3)}">盘点中({!! $inventory->id !!})</a>
+                <a  class="nav-link" href="{{URL::current()}}" :class="{active:isActive('enterStockInventory',3)}">盘点中({!! $inventoryAccount->id !!})</a>
             </li>
         @endcomponent
     <div id="list" class="container-fluid" style="min-width: 1500px">
@@ -91,7 +91,8 @@
                 <th>盘点差异</th>
                 <th>分配数量</th>
             </tr>
-            <tr v-for="(inventoryMission,i) in inventoryMissions" v-if="inventoryMission.checked=='是'" @click="selectedColor(inventoryMission.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
+
+            <tr v-for="(inventoryMission,i) in inventoryMissions" v-if="inventoryMission.checked=='是'"  @click="selectedColor(inventoryMission.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
                 <td>@{{ i+1 }}</td>
                 <td>@{{ inventoryMission.location }}</td>
                 <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
@@ -120,8 +121,8 @@
         let listVue = new Vue({
             el: "#list",
             data: {
-                inventory:{!! $inventory!!},
-                inventoryMissions:{!! $inventoryMissions !!},
+                inventory:{!! $inventoryAccount!!},
+                inventoryMissions:{!! $inventoryAccountMissions !!},
                 checkData: [],
                 selectedStyle:'',
                 inventoryMissionRecord:{},

+ 100 - 53
resources/views/inventory/stockInventory/mission.blade.php

@@ -5,22 +5,27 @@
 @section('content')
     @component('inventory.stockInventory.menu')@endcomponent
     <div id="list" class="container-fluid" style="min-width: 1500px">
-        <div id="form_div"></div>
-        <span class="dropdown">
-        <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="inventoryExport(false)" href="javascript:">导出勾选内容</a>
-            <a class="dropdown-item" @click="inventoryExport(true)" href="javascript:">导出所有页</a>
-        </div>
-    </span>
-        @can('库存管理-盘点')
-            <span v-if="formData.date_start&&formData.date_end" class="btn btn-sm  btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成动盘任务</span>
-            <span v-else class="btn btn-sm btn-outline-secondary  tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成全盘任务</span>
-        @endcan
-        <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
+        {{--        <div id="form_div"></div>--}}
+        <form class="form-inline mt-3">
+            <span class="form-inline ml-5">
+                <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 150px" title="选择指定货主">
+                    <option value="">货主</option>
+                    <option v-for="owner in owners" :value="owner.name">@{{ owner.value }}</option>
+                </select>
+            </span>
+            <span class="form-inline">
+                <input type="date" @change="hasDateStart" class="form-control form-control-sm ml-5 tooltipTarget" name="date_start" id="date_start"  title="选择创建日期的开始时间" style="width: 150px">
+                <input type="date" @change="hasDateEnd" class="form-control form-control-sm ml-5 tooltipTarget" name="date_end" id="date_end"  title="选择创建日期的结束时间" style="width: 150px">
+            </span>
+            <span class="ml-5">
+            @can('库存管理-盘点')
+                    <span v-if="date_start&&date_end" class="btn btn-sm  btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成动盘任务</span>
+                    <span v-else class="btn btn-sm btn-outline-secondary  tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成全盘任务</span>
+                @endcan
+            </span>
+        </form>
+
+        <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-3">
             <tr>
                 <th>
                     <label for="all">
@@ -42,7 +47,7 @@
                 <th>复盘归位</th>
                 <th>操作</th>
             </tr>
-            <tr v-for="(inventory,i) in inventories" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
+            <tr v-for="(inventory,i) in inventoryAccounts" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
                 <td>
                     <input class="checkItem" type="checkbox" :value="inventory.id" v-model="checkData">
                 </td>
@@ -66,8 +71,18 @@
                 </td>
             </tr>
         </table>
-        <div class="text-info h5 btn btn">{{$inventories->count()}}/@{{ sum }}</div>
-        <div>{{$inventories->appends($paginateParams)->links()}}</div>
+        <div class="text-info h5 btn btn">{{$inventoryAccounts->count()}}/@{{ sum }}</div>
+        <div>{{$inventoryAccounts->appends($paginateParams)->links()}}</div>
+        <span class="dropdown">
+        <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="inventoryExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="inventoryExport(true)" href="javascript:">导出所有页</a>
+        </div>
+        </span>
     </div>
 
 @endsection
@@ -79,7 +94,7 @@
         new Vue({
             el: "#list",
             data: {
-                inventories:{!! $inventories->toJson()!!}['data'],
+                inventoryAccounts:{!! $inventoryAccounts->toJson()!!}['data'],
                 owners: [
                         @foreach($owners as $owner)
                     {
@@ -89,27 +104,29 @@
                 ],
                 checkData: [],
                 selectedStyle:'',
-                sum:{!! $inventories->total() !!},
-                formData:{},
+                sum:{!! $inventoryAccounts->total() !!},
+                // formData:{},
+                date_end:'',
+                date_start:'',
             },
             mounted: function () {
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
                 $("#list").removeClass('d-none');
-                let data=[
-                    [
-                        {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
-                            placeholder:['货主','定位或多选货主'],data:this.owners},
-                        {name:'date_start',type:'dateTime',tip:'选择创建日期的开始时间',},
-                        {name:'date_end',type:'dateTime',tip:'选择创建日期的结束时间',},
-                    ],
-                ];
-                this.form = new query({
-                    el:'#form_div',
-                    condition:data,
-                });
-                this.form.init();
-                let obj=this.form.getSearchData();
-                this.formData=obj;
+                // let data=[
+                //     [
+                //         {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
+                //             placeholder:['货主','定位或多选货主'],data:this.owners},
+                //         {name:'date_start',type:'dateTime',tip:'选择创建日期的开始时间',},
+                //         {name:'date_end',type:'dateTime',tip:'选择创建日期的结束时间',},
+                //     ],
+                // ];
+                // this.form = new query({
+                //     el:'#form_div',
+                //     condition:data,
+                // });
+                // this.form.init();
+                // let obj=this.form.getSearchData();
+                // this.formData=obj;
             },
             methods:{
                 selectedColor(id){
@@ -138,32 +155,56 @@
                 //生成盘点任务
                 createInventoryMission(){
                     let _this=this;
-                    if (_this.formData.owner_id.length<=0){
-                        tempTip.setDuration(1000);
+                    const date_end=document.getElementById('date_end').value;
+                    const date_start=document.getElementById('date_start').value;
+                    const owner_id=document.getElementById('owner_id').value;
+                    if(document.getElementById('owner_id').value==''){
+                        tempTip.setDuration(2000);
                         tempTip.show('生成盘点任务失败'+'   '+'请先选择货主!');
                         return;
                     }
+                    if(!date_end && date_start){
+                        tempTip.setDuration(2000);
+                        tempTip.show('生成盘点任务失败'+'   '+'请选择结束时间!');
+                        return;
+                    }
+                    if(date_end && !date_start){
+                        tempTip.setDuration(2000);
+                        tempTip.show('生成盘点任务失败'+'   '+'请选择开始时间!');
+                        return;
+                    }
+                    tempTip.setDuration(99999);
+                    tempTip.waitingTip('生成任务中');
+                    // if (_this.formData.owner_id.length<=0){
+                    //     tempTip.setDuration(1000);
+                    //     tempTip.show('生成盘点任务失败'+'   '+'请先选择货主!');
+                    //     return;
+                    // }
                     let url='{{url('inventory/stockInventory/createStockInventoryMission')}}';
-                    axios.post(url,{formData:_this.formData}).then(function (response) {
-                            if(!response.data.success){
-                                tempTip.setDuration(1000);
-                                tempTip.show('生成盘点任务失败'+'   '+response.data.data);
-                                return;
-                            }else{
-                                let inventory=response.data.data;
-                                _this.inventories.push(inventory);
-                                tempTip.setDuration(2000);
-                                tempTip.showSuccess('生成盘点任务成功!');
-                            }
-                        })
-                        .catch(function (err) {
+                    axios.post(url,{date_end:date_end,date_start:date_start,owner_id:owner_id}).then(function (response) {
+                        tempTip.setDuration(2000);
+                        tempTip.cancelWaitingTip();
+                        if(!response.data.success){
+                            tempTip.setDuration(1000);
+                            tempTip.show('生成盘点任务失败'+'   '+response.data.data);
+                            return;
+                        }else{
+                            let inventory=response.data.data;
+                            //_this.inventories.push(inventory);
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess('生成盘点任务成功!');
+                            // tempTip.setDuration(99999);
+                            // tempTip.waitingTip('页面跳转中');
+                            location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id;
+                        }
+                    }).catch(function (err) {
                             tempTip.setDuration(3000);
                             tempTip.show('生成盘点任务失败!'+'网络错误:' + err);
                         });
                 },
                 //进入盘点中页面  或者复盘页面
                 enterStockInventory(id){
-                        location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+id;
+                    location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+id;
                 },
                 //删除盘点任务
                 deleteStockInventoryMission(id){
@@ -187,6 +228,12 @@
                         tempTip.show('删除失败,网络链接错误!'+err);
                     });
                 },
+                hasDateStart(){
+                  this.date_start=document.getElementById('date_start').value;
+                },
+                hasDateEnd(){
+                    this.date_end=document.getElementById('date_end').value;
+                },
             }
         });
     </script>

+ 8 - 7
routes/web.php

@@ -299,20 +299,21 @@ Route::group(['prefix'=>'inventory'],function (){
     Route::post('statement/changeInventory/deleteExcel','InventoryController@deleteExcel');
     //全部库存
     Route::get('statement/allInventory','InventoryController@allInventory');
+
     //库存盘点
-    Route::get('stockInventory/mission','InventoryController@mission');
+    Route::get('stockInventory/mission','InventoryAccountController@mission');
     //创建盘点任务
-    Route::post('stockInventory/createStockInventoryMission','InventoryController@createStockInventoryMission');
+    Route::post('stockInventory/createStockInventoryMission','InventoryAccountController@createStockInventoryMission');
     //删除盘点任务
-    Route::any('deleteStockInventoryMission/{id}','InventoryController@deleteStockInventoryMission');
+    Route::any('deleteStockInventoryMission/{id}','InventoryAccountController@deleteStockInventoryMission');
     //进入盘点或者复盘页面
-    Route::any('stockInventory/enterStockInventory/{id}','InventoryController@enterStockInventory');
+    Route::any('stockInventory/enterStockInventory/{id}','InventoryAccountController@enterStockInventory');
     //盘点任务导出
-    Route::any('stockInventoryExport','InventoryController@stockInventoryExport');
+    Route::any('stockInventoryExport','InventoryAccountController@stockInventoryExport');
     //盘点库存
-    Route::any('stockInventory','InventoryController@stockInventory');
+    Route::any('stockInventory','InventoryAccountController@stockInventory');
     //复盘查询盘点记录
-    Route::post('searchStockInventoryRecord','InventoryController@searchStockInventoryRecord');
+    Route::post('searchStockInventoryRecord','InventoryAccountController@searchStockInventoryRecord');
 
 
 });

+ 27 - 0
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_ConditionSearchTest.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace Tests\Inventory\Services\InventoryAccountService;
+
+
+use App\Services\InventoryAccountService;
+use Tests\TestCase;
+
+class InventoryServiceConditionSearchTest extends TestCase
+{
+    public $data;
+    public $ownerId=null;
+    function testConditionSearchFail(){
+        $inventoryService=new InventoryAccountService();
+        $this->data=$inventoryService->conditionPortStock('','',$this->ownerId);
+        $this->assertNull($this->data);
+    }
+    function testConditionSearchCanSearchData(){
+        $inventoryService=new InventoryAccountService();
+        $this->ownerId=3;
+        $this->data=$inventoryService->conditionPortStock('2020-08-19','2020-08-19',$this->ownerId);
+        $this->assertNotEmpty($this->data);
+    }
+
+}
+

+ 14 - 12
tests/Inventory/Services/InventoryService/InventoryService_CreateInventoryMissionRecordTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php

@@ -1,12 +1,12 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
-use App\Inventory;
-use App\InventoryMission;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
 class InventoryServiceCreateInventoryMissionRecordTest extends TestCase
@@ -14,26 +14,28 @@ class InventoryServiceCreateInventoryMissionRecordTest extends TestCase
 
     public $inventory;
     public $inventoryMissions;
+    public $realService;
+    public $wmsInventoryAccounts;
     function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $this->inventory=factory(Inventory::class)->create();
+        $this->inventory=factory(InventoryAccount::class)->create();
+        $this->realService=new InventoryAccountService();
+        $this->wmsInventoryAccounts=$this->realService->conditionPortStock('2020-08-20','2020-08-20',3);
     }
         function testCreateInventoryMissionsFail(){
-        $realService=new InventoryService();
-        $inventoryMissions=$realService->createInventoryMissionRecord('2020-08-20','2020-08-20','',$this->inventory['id']);
+        $inventoryMissions= $this->realService->createInventoryAccountMissionRecord('',$this->inventory['id'],$this->wmsInventoryAccounts);
         $this->assertNull($inventoryMissions);
     }
     function testCreateInventoryMissionsSuccess(){
-        $realService=new InventoryService();
-        $realService->createInventoryMissionRecord('2020-08-20','2020-08-20',3,$this->inventory['id']);
-        $this->inventoryMissions=InventoryMission::where('inventory_id',$this->inventory['id'])->get();
+        $this->realService->createInventoryAccountMissionRecord(3,$this->inventory['id'],$this->wmsInventoryAccounts);
+        $this->inventoryMissions=InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->get();
         $this->assertNotEmpty($this->inventoryMissions);
     }
     function tearDown(): void
     {
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 

+ 9 - 9
tests/Inventory/Services/InventoryService/InventoryService_CreateMissionTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateMissionTest.php

@@ -1,15 +1,15 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
-use App\Inventory;
-use App\InventoryMission;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
-class InventoryService_CreateMissionTest extends TestCase
+class InventoryAccountService_CreateMissionTest extends TestCase
 {
 
     public $inventory;
@@ -19,20 +19,20 @@ class InventoryService_CreateMissionTest extends TestCase
         parent::setUp(); // TODO: Change the autogenerated stub
     }
         function testCreateMissionsFail(){
-        $realService=new InventoryService();
+        $realService=new InventoryAccountService();
         $this->inventory=$realService->createMission('2020-08-20','2020-08-20','');
         $this->assertNull($this->inventory);
     }
     function testCreateMissionsSuccess(){
-        $realService=new InventoryService();
+        $realService=new InventoryAccountService();
         $this->inventory=$realService->createMission('2020-08-20','2020-08-20',3);
         $this->assertIsObject($this->inventory);
         $this->assertNotEmpty($this->inventory);
     }
     function tearDown(): void
     {
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 

+ 6 - 6
tests/Inventory/Services/InventoryService/InventoryService_GetTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_GetTest.php

@@ -1,22 +1,22 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
-use App\Inventory;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
-class InventoryService_GetTest extends TestCase
+class InventoryAccountService_GetTest extends TestCase
 {
     public $inventories;
     public $inventorys;
     public $queryParam=[];
     function testGet(){
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $this->inventories=$inventoryService->get($this->queryParam);
-        $this->inventorys=Inventory::with(['owner'])->orderBy('id','desc')->get();
+        $this->inventorys=InventoryAccount::with(['owner'])->orderBy('id','desc')->get();
         $this->assertEquals(count($this->inventorys),count($this->inventories));
         $this->assertEquals($this->inventorys,$this->inventories);
     }

+ 8 - 8
tests/Inventory/Services/InventoryService/InventoryService_PaginateTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_PaginateTest.php

@@ -1,23 +1,23 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
-use App\Inventory;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
-class InventoryService_PaginateTest extends TestCase
+class InventoryAccountService_PaginateTest extends TestCase
 {
     public $inventories;
     public $inventorys;
     public $queryParam=[];
     //没有任何搜索条件情况
     function testPaginateSuccess(){
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $this->inventories=$inventoryService->paginate($this->queryParam);
-        $this->inventorys=Inventory::get();
+        $this->inventorys=InventoryAccount::get();
         $this->assertEquals(count($this->inventorys),$this->inventories->total());
         $this->assertEquals(50,$this->inventories->perPage());
     }
@@ -27,9 +27,9 @@ class InventoryService_PaginateTest extends TestCase
             "owner_id" => "3",
             "paginate" => "100",
         ];
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $this->inventories=$inventoryService->paginate($this->queryParam);
-        $this->inventorys=Inventory::where('owner_id',3)->get();
+        $this->inventorys=InventoryAccount::where('owner_id',3)->get();
         $this->assertEquals(count($this->inventorys),$this->inventories->total());
         $this->assertEquals(100,$this->inventories->perPage());
     }

+ 11 - 11
tests/Inventory/Services/InventoryService/InventoryService_SearchStockInventoryRecordTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SearchStockInventoryRecordTest.php

@@ -1,14 +1,14 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
 use App\Commodity;
 use App\CommodityBarcode;
-use App\Inventory;
-use App\InventoryMission;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
 class InventoryServiceSearchStockInventoryRecordTest extends TestCase
@@ -29,9 +29,9 @@ class InventoryServiceSearchStockInventoryRecordTest extends TestCase
             'code'=>'89898989',
             'commodity_id'=>$this->commodity['id'],
         ]);
-        $this->inventory=factory(Inventory::class)->create();
-        $this->inventoryMission=InventoryMission::create([
-            'inventory_id'=>$this->inventory['id'],
+        $this->inventory=factory(InventoryAccount::class)->create();
+        $this->inventoryMission=InventoryAccountMission::create([
+            'inventory_account_id'=>$this->inventory['id'],
             'location'=>'A21-02-02',
             'commodity_id'=>$this->commodity['id'],
             'produced_at'=>null,
@@ -51,12 +51,12 @@ class InventoryServiceSearchStockInventoryRecordTest extends TestCase
         ]);
     }
     function testSearchStockInventoryNotEmpty(){
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $inventoryMission=$inventoryService->searchStockInventoryRecord('A21-02-02','89898989',$this->inventory['id']);
         $this->assertNotEmpty($inventoryMission);
     }
     function testSearchStockInventoryEmpty(){
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $inventoryMission=$inventoryService->searchStockInventoryRecord('','',$this->inventory['id']);
         $this->assertEmpty($inventoryMission);
     }
@@ -65,8 +65,8 @@ class InventoryServiceSearchStockInventoryRecordTest extends TestCase
     {
         CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
         Commodity::where('id',$this->commodity['id'])->delete();
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 10 - 10
tests/Inventory/Services/InventoryService/InventoryService_SomeTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SomeTest.php

@@ -1,14 +1,14 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
-use App\Inventory;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
-class InventoryService_SomeTest extends TestCase
+class InventoryAccountService_SomeTest extends TestCase
 {
     public $inventories;
     public $inventorys;
@@ -18,25 +18,25 @@ class InventoryService_SomeTest extends TestCase
     function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $this->first=factory(Inventory::class)->create();
-        $this->second=factory(Inventory::class)->create();
+        $this->first=factory(InventoryAccount::class)->create();
+        $this->second=factory(InventoryAccount::class)->create();
     }
 
     function testSome(){
         $this->queryParam=[
             'data'=>'"'.$this->first['id'].','.$this->second['id'].'"',
         ];
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $this->inventories=$inventoryService->some($this->queryParam);
-        $this->inventorys=Inventory::query()->with(['owner'])->orderBy('id','DESC')
+        $this->inventorys=InventoryAccount::query()->with(['owner'])->orderBy('id','DESC')
             ->whereIn('id',explode(',','"'.$this->first['id'].','.$this->second['id'].'"'))->get();
         $this->assertEquals(count($this->inventorys),count($this->inventories));
         $this->assertEquals($this->inventorys,$this->inventories);
     }
     function tearDown(): void
     {
-        Inventory::where('id',$this->first['id'])->forceDelete();
-        Inventory::where('id',$this->second['id'])->forceDelete();
+        InventoryAccount::where('id',$this->first['id'])->forceDelete();
+        InventoryAccount::where('id',$this->second['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 

+ 10 - 10
tests/Inventory/Services/InventoryService/InventoryService_StockInventoryTest.php → tests/Inventory/Services/InventoryAccountService/InventoryAccountService_StockInventoryTest.php

@@ -1,14 +1,14 @@
 <?php
 
 
-namespace Tests\Inventory\Services\InventoryService;
+namespace Tests\Inventory\Services\InventoryAccountService;
 
 
 use App\Commodity;
 use App\CommodityBarcode;
-use App\Inventory;
-use App\InventoryMission;
-use App\Services\InventoryService;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
+use App\Services\InventoryAccountService;
 use Tests\TestCase;
 
 class InventoryServiceStockInventoryTest extends TestCase
@@ -29,9 +29,9 @@ class InventoryServiceStockInventoryTest extends TestCase
             'code'=>'89898989',
             'commodity_id'=>$this->commodity['id'],
         ]);
-        $this->inventory=factory(Inventory::class)->create();
-        $this->inventoryMission=InventoryMission::create([
-            'inventory_id'=>$this->inventory['id'],
+        $this->inventory=factory(InventoryAccount::class)->create();
+        $this->inventoryMission=InventoryAccountMission::create([
+            'inventory_account_id'=>$this->inventory['id'],
             'location'=>'A21-02-02',
             'commodity_id'=>$this->commodity['id'],
             'produced_at'=>null,
@@ -51,7 +51,7 @@ class InventoryServiceStockInventoryTest extends TestCase
         ]);
     }
     function testStockInventoryNoDifferenceAndStockSuccess(){
-        $inventoryService=new InventoryService();
+        $inventoryService=new InventoryAccountService();
         $inventoryMission=$inventoryService->stockInventory('A21-02-02','89898989','50',$this->inventory['id']);
         $this->assertEquals('是',$inventoryMission['checked']);
         $this->assertEquals(0,$inventoryMission['difference_amount']);
@@ -62,8 +62,8 @@ class InventoryServiceStockInventoryTest extends TestCase
     {
         CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
         Commodity::where('id',$this->commodity['id'])->delete();
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 0 - 27
tests/Inventory/Services/InventoryService/InventoryService_ConditionSearchTest.php

@@ -1,27 +0,0 @@
-<?php
-
-
-namespace Tests\Inventory\Services\InventoryService;
-
-
-use App\Services\InventoryService;
-use Tests\TestCase;
-
-class InventoryServiceConditionSearchTest extends TestCase
-{
-    public $data;
-    public $ownerId=null;
-    function testConditionSearchFail(){
-        $inventoryService=new InventoryService();
-        $this->data=$inventoryService->conditionSearch('','',$this->ownerId);
-        $this->assertNull($this->data);
-    }
-    function testConditionSearchCanSearchData(){
-        $inventoryService=new InventoryService();
-        $this->ownerId=3;
-        $this->data=$inventoryService->conditionSearch('2020-08-19','2020-08-19',$this->ownerId);
-        $this->assertNotEmpty($this->data);
-    }
-
-}
-

+ 8 - 9
tests/Inventory/http/InventoryControllor/InventoryController_CreateStockInventoryMissionTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_CreateStockInventoryMissionTest.php

@@ -5,15 +5,14 @@ namespace Tests\Inventory\Http\InventoryController;
 
 
 use App\Authority;
-use App\Inventory;
-use App\InventoryMission;
-use App\Owner;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\Role;
 use App\User;
 use Illuminate\Support\Facades\DB;
 use Tests\TestCase;
 
-class InventoryControllerCreateStockInventoryMissionTestMissionTest extends TestCase
+class InventoryAccountController_CreateStockInventoryMissionTest extends TestCase
 {
     public $response=null;
     public $role;
@@ -33,11 +32,11 @@ class InventoryControllerCreateStockInventoryMissionTestMissionTest extends Test
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
         }
         $this->response=$this->actingAs($this->user)->json('post','http://bswas/inventory/stockInventory/createStockInventoryMission/',
-            ['formData'=>[
+            [
                 'date_end'=>'2020-08-17',
                 'date_start'=>'2020-08-17',
-                'owner_id'=>[3],
-            ]]);
+                'owner_id'=>3,
+            ]);
     }
     function testCreateStockInventoryMissionNotHavingException(){
         $this->response->assertDontSee('Exception');
@@ -54,8 +53,8 @@ class InventoryControllerCreateStockInventoryMissionTestMissionTest extends Test
         DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
         User::where('id',$this->user['id'])->delete();
         Role::where('id',$this->role['id'])->delete();
-        InventoryMission::where('inventory_id',$this->response->json()['data']['id'])->delete();
-        Inventory::where('id',$this->response->json()['data']['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->response->json()['data']['id'])->delete();
+        InventoryAccount::where('id',$this->response->json()['data']['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 3 - 3
tests/Inventory/http/InventoryControllor/InventoryController_DeleteStockInventoryMissionTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_DeleteStockInventoryMissionTest.php

@@ -5,7 +5,7 @@ namespace Tests\Inventory\Http\InventoryController;
 
 
 use App\Authority;
-use App\Inventory;
+use App\InventoryAccount;
 use App\Owner;
 use App\Role;
 use App\User;
@@ -30,7 +30,7 @@ class InventoryControllerDeleteStockInventoryMissionTestMissionTest extends Test
             $authority= Authority::where('name','库存管理-盘点')->first();
             DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
-            $this->inventory=factory(Inventory::class)->create();
+            $this->inventory=factory(InventoryAccount::class)->create();
         }
         $this->response=$this->actingAs($this->user)->json('delete','http://bswas/inventory/deleteStockInventoryMission/'.$this->inventory['id']);
     }
@@ -47,7 +47,7 @@ class InventoryControllerDeleteStockInventoryMissionTestMissionTest extends Test
         DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
         User::where('id',$this->user['id'])->delete();
         Role::where('id',$this->role['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 10 - 10
tests/Inventory/http/InventoryControllor/InventoryController_EnterStockInventoryTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_EnterStockInventoryTest.php

@@ -6,11 +6,11 @@ namespace Tests\Inventory\Http\InventoryController;
 
 use App\Authority;
 use App\Commodity;
-use App\Inventory;
-use App\InventoryMission;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\Owner;
 use App\Role;
-use App\Services\InventoryService;
+use App\Services\InventoryAccountService;
 use App\Services\UnitService;
 use App\User;
 use Illuminate\Database\Eloquent\Collection;
@@ -37,11 +37,11 @@ class InventoryControllerEnterStockInventoryMissionTestTest extends TestCase
             $authority= Authority::where('name','库存管理-盘点')->first();
             DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
-            $this->inventory=factory(Inventory::class)->create();
+            $this->inventory=factory(InventoryAccount::class)->create();
             $total=$this->inventory['total'];
             for ($i=0;$i<$total;$i++){
-                $this->inventoryMissions=InventoryMission::create([
-                    'inventory_id'=>$this->inventory['id'],
+                $this->inventoryMissions=InventoryAccountMission::create([
+                    'inventory_account_id'=>$this->inventory['id'],
                     'location'=>Str::random(5),
                     'commodity_id'=>256226,
                     'produced_at'=>null,
@@ -74,8 +74,8 @@ class InventoryControllerEnterStockInventoryMissionTestTest extends TestCase
     function testStockInventoryViewHasInventoryAndInventoryMissions(){
         //$inventory=Inventory::with('owner')->find($this->inventory['id']);
         //$inventoryMissions=InventoryMission::with(['commodity'])->where('inventory_id',$this->inventory['id'])->orderBy('difference_amount','desc')->get();
-        $this->response->assertViewHas('inventoryMissions');
-        $this->response->assertViewHas('inventory');
+        $this->response->assertViewHas('inventoryAccountMissions');
+        $this->response->assertViewHas('inventoryAccount');
     }
     function tearDown(): void
     {
@@ -83,8 +83,8 @@ class InventoryControllerEnterStockInventoryMissionTestTest extends TestCase
         DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
         User::where('id',$this->user['id'])->delete();
         Role::where('id',$this->role['id'])->delete();
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 1 - 1
tests/Inventory/http/InventoryControllor/InventoryController_MissionTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_MissionTest.php

@@ -44,7 +44,7 @@ class InventoryControllerMissionTest extends TestCase
         $this->response->assertViewHas('owners',$owners);
     }
     function testMissionHasInventories(){
-        $this->response->assertViewHas('inventories');
+        $this->response->assertViewHas('inventoryAccounts');
     }
 
     function tearDown(): void

+ 7 - 7
tests/Inventory/http/InventoryControllor/InventoryController_SearchStockInventoryRecordTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_SearchStockInventoryRecordTest.php

@@ -5,8 +5,8 @@ namespace Tests\Inventory\Http\InventoryController;
 
 
 use App\Authority;
-use App\Inventory;
-use App\InventoryMission;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\Owner;
 use App\Role;
 use App\User;
@@ -33,9 +33,9 @@ class InventoryController_SearchStockInventoryRecordTest extends TestCase
             $authority= Authority::where('name','库存管理-盘点')->first();
             DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
-            $this->inventory=factory(Inventory::class)->create();
-            $this->inventoryMissions=InventoryMission::create([
-                'inventory_id'=>$this->inventory['id'],
+            $this->inventory=factory(InventoryAccount::class)->create();
+            $this->inventoryMissions=InventoryAccountMission::create([
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>'A12-10-01',
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -76,8 +76,8 @@ class InventoryController_SearchStockInventoryRecordTest extends TestCase
         DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
         User::where('id',$this->user['id'])->delete();
         Role::where('id',$this->role['id'])->delete();
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 7 - 7
tests/Inventory/http/InventoryControllor/InventoryController_StockInventoryTest.php → tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_StockInventoryTest.php

@@ -5,8 +5,8 @@ namespace Tests\Inventory\Http\InventoryController;
 
 
 use App\Authority;
-use App\Inventory;
-use App\InventoryMission;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use App\Owner;
 use App\Role;
 use App\User;
@@ -32,9 +32,9 @@ class InventoryControllerStockInventoryMissionTestTest extends TestCase
             $authority= Authority::where('name','库存管理-盘点')->first();
             DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
-            $this->inventory=factory(Inventory::class)->create();
-            $this->inventoryMissions=InventoryMission::create([
-                'inventory_id'=>$this->inventory['id'],
+            $this->inventory=factory(InventoryAccount::class)->create();
+            $this->inventoryMissions=InventoryAccountMission::create([
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>'A12-10-01',
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -84,8 +84,8 @@ class InventoryControllerStockInventoryMissionTestTest extends TestCase
         DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
         User::where('id',$this->user['id'])->delete();
         Role::where('id',$this->role['id'])->delete();
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }

+ 12 - 12
tests/Inventory/model/InventoryTest.php → tests/Inventory/model/InventoryAccountTest.php

@@ -4,14 +4,14 @@
 namespace Tests\Inventory\model;
 
 
-use App\Inventory;
-use App\InventoryMission;
+use App\InventoryAccount;
+use App\InventoryAccountMission;
 use Illuminate\Support\Str;
 use Tests\TestCase;
 
 
 
-class InventoryTest extends TestCase
+class InventoryAccountTest extends TestCase
 {
 
     public $inventory;
@@ -19,11 +19,11 @@ class InventoryTest extends TestCase
     function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $this->inventory=factory(Inventory::class)->create();
+        $this->inventory=factory(InventoryAccount::class)->create();
         $total=$this->inventory['total'];
         for ($i=0;$i<$total;$i++){
-            $this->inventoryMissions=InventoryMission::create([
-                'inventory_id'=>$this->inventory['id'],
+            $this->inventoryMissions=InventoryAccountMission::create([
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>Str::random(5),
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -49,29 +49,29 @@ class InventoryTest extends TestCase
     }
 
     function testInventoryMissions(){
-        $this->assertEquals($this->inventory->id,$this->inventory->inventoryMissions['inventory_id']);
+        $this->assertEquals($this->inventory->id,$this->inventory->inventoryMissions['inventory_account_id']);
     }
     function testGetSurplusAttribute(){
         $surplus=$this->inventory['surplus'];
         $this->assertEquals($surplus,$this->inventory['total']-$this->inventory['processed']);
     }
     function testGetProcessedAmount(){
-        $processed=InventoryMission::where('inventory_id',$this->inventory['id'])->where('checked','是')->count();
+        $processed=InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->where('checked','是')->count();
         $this->assertEquals($processed,$this->inventory['processed']);
     }
     function testGetDifferenceAmount(){
-        $difference=InventoryMission::where('inventory_id',$this->inventory['id'])->where('difference_amount','>',0)->count();
+        $difference=InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->where('difference_amount','>',0)->count();
         $this->assertEquals($difference,$this->inventory['difference']);
     }
     function testGetReturnedAmount(){
-        $returned=InventoryMission::where('inventory_id',$this->inventory['id'])->where('returned','是')->count();
+        $returned=InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->where('returned','是')->count();
         $this->assertEquals($returned,$this->inventory['returned']);
     }
 
     function tearDown(): void
     {
-        InventoryMission::where('inventory_id',$this->inventory['id'])->delete();
-        Inventory::where('id',$this->inventory['id'])->forceDelete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
+        InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }