haozi 5 лет назад
Родитель
Сommit
1ed1904d1e
15 измененных файлов с 53 добавлено и 43 удалено
  1. 1 1
      app/Services/InventoryAccountService.php
  2. 1 1
      database/factories/InventoryMissionFactory.php
  3. 2 2
      resources/views/inventory/stockInventory/inventoryMission.blade.php
  4. 14 5
      resources/views/inventory/stockInventory/mission.blade.php
  5. 2 2
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_ConditionSearchTest.php
  6. 8 6
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php
  7. 1 1
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateMissionTest.php
  8. 2 2
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SearchStockInventoryRecordTest.php
  9. 2 2
      tests/Inventory/Services/InventoryAccountService/InventoryAccountService_StockInventoryTest.php
  10. 5 6
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_CreateStockInventoryMissionTest.php
  11. 4 4
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_EnterStockInventoryTest.php
  12. 1 1
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_MissionTest.php
  13. 2 2
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_SearchStockInventoryRecordTest.php
  14. 2 2
      tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_StockInventoryTest.php
  15. 6 6
      tests/Inventory/model/InventoryAccountTest.php

+ 1 - 1
app/Services/InventoryAccountService.php

@@ -46,7 +46,7 @@ class InventoryAccountService
             ->whereIn('id',explode(',',$queryParam['data']))->get();
     }
     //动盘查询
-    private function conditionPortStock($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 (';

+ 1 - 1
database/factories/InventoryMissionFactory.php

@@ -10,7 +10,7 @@ use Illuminate\Support\Str;
 $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'=>'',

+ 2 - 2
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -91,8 +91,8 @@
                 <th>盘点差异</th>
                 <th>分配数量</th>
             </tr>
-{{--            v-if="inventoryMission.checked=='是'"--}}
-            <tr v-for="(inventoryMission,i) in inventoryMissions"  @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>

+ 14 - 5
resources/views/inventory/stockInventory/mission.blade.php

@@ -155,11 +155,24 @@
                 //生成盘点任务
                 createInventoryMission(){
                     let _this=this;
+                    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){
@@ -167,9 +180,6 @@
                     //     tempTip.show('生成盘点任务失败'+'   '+'请先选择货主!');
                     //     return;
                     // }
-                    const date_end=document.getElementById('date_end').value;
-                    const date_start=document.getElementById('date_start').value;
-                    const owner_id=document.getElementById('owner_id').value;
                     let url='{{url('inventory/stockInventory/createStockInventoryMission')}}';
                     axios.post(url,{date_end:date_end,date_start:date_start,owner_id:owner_id}).then(function (response) {
                         tempTip.setDuration(2000);
@@ -187,8 +197,7 @@
                             // tempTip.waitingTip('页面跳转中');
                             location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id;
                         }
-                    })
-                        .catch(function (err) {
+                    }).catch(function (err) {
                             tempTip.setDuration(3000);
                             tempTip.show('生成盘点任务失败!'+'网络错误:' + err);
                         });

+ 2 - 2
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_ConditionSearchTest.php

@@ -13,13 +13,13 @@ class InventoryServiceConditionSearchTest extends TestCase
     public $ownerId=null;
     function testConditionSearchFail(){
         $inventoryService=new InventoryAccountService();
-        $this->data=$inventoryService->conditionSearch('','',$this->ownerId);
+        $this->data=$inventoryService->conditionPortStock('','',$this->ownerId);
         $this->assertNull($this->data);
     }
     function testConditionSearchCanSearchData(){
         $inventoryService=new InventoryAccountService();
         $this->ownerId=3;
-        $this->data=$inventoryService->conditionSearch('2020-08-19','2020-08-19',$this->ownerId);
+        $this->data=$inventoryService->conditionPortStock('2020-08-19','2020-08-19',$this->ownerId);
         $this->assertNotEmpty($this->data);
     }
 

+ 8 - 6
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_CreateInventoryMissionRecordTest.php

@@ -14,25 +14,27 @@ 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(InventoryAccount::class)->create();
+        $this->realService=new InventoryAccountService();
+        $this->wmsInventoryAccounts=$this->realService->conditionPortStock('2020-08-20','2020-08-20',3);
     }
         function testCreateInventoryMissionsFail(){
-        $realService=new InventoryAccountService();
-        $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 InventoryAccountService();
-        $realService->createInventoryMissionRecord('2020-08-20','2020-08-20',3,$this->inventory['id']);
-        $this->inventoryMissions=InventoryAccountMission::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
     {
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        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/Services/InventoryAccountService/InventoryAccountService_CreateMissionTest.php

@@ -31,7 +31,7 @@ class InventoryAccountService_CreateMissionTest extends TestCase
     }
     function tearDown(): void
     {
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
         InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }

+ 2 - 2
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_SearchStockInventoryRecordTest.php

@@ -31,7 +31,7 @@ class InventoryServiceSearchStockInventoryRecordTest extends TestCase
         ]);
         $this->inventory=factory(InventoryAccount::class)->create();
         $this->inventoryMission=InventoryAccountMission::create([
-            'inventory_id'=>$this->inventory['id'],
+            'inventory_account_id'=>$this->inventory['id'],
             'location'=>'A21-02-02',
             'commodity_id'=>$this->commodity['id'],
             'produced_at'=>null,
@@ -65,7 +65,7 @@ class InventoryServiceSearchStockInventoryRecordTest extends TestCase
     {
         CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
         Commodity::where('id',$this->commodity['id'])->delete();
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
         InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }

+ 2 - 2
tests/Inventory/Services/InventoryAccountService/InventoryAccountService_StockInventoryTest.php

@@ -31,7 +31,7 @@ class InventoryServiceStockInventoryTest extends TestCase
         ]);
         $this->inventory=factory(InventoryAccount::class)->create();
         $this->inventoryMission=InventoryAccountMission::create([
-            'inventory_id'=>$this->inventory['id'],
+            'inventory_account_id'=>$this->inventory['id'],
             'location'=>'A21-02-02',
             'commodity_id'=>$this->commodity['id'],
             'produced_at'=>null,
@@ -62,7 +62,7 @@ class InventoryServiceStockInventoryTest extends TestCase
     {
         CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
         Commodity::where('id',$this->commodity['id'])->delete();
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
         InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }

+ 5 - 6
tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_CreateStockInventoryMissionTest.php

@@ -7,13 +7,12 @@ namespace Tests\Inventory\Http\InventoryController;
 use App\Authority;
 use App\InventoryAccount;
 use App\InventoryAccountMission;
-use App\Owner;
 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,7 +53,7 @@ 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();
-        InventoryAccountMission::where('inventory_id',$this->response->json()['data']['id'])->delete();
+        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
     }

+ 4 - 4
tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_EnterStockInventoryTest.php

@@ -41,7 +41,7 @@ class InventoryControllerEnterStockInventoryMissionTestTest extends TestCase
             $total=$this->inventory['total'];
             for ($i=0;$i<$total;$i++){
                 $this->inventoryMissions=InventoryAccountMission::create([
-                    'inventory_id'=>$this->inventory['id'],
+                    '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,7 +83,7 @@ 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();
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        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/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

+ 2 - 2
tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_SearchStockInventoryRecordTest.php

@@ -35,7 +35,7 @@ class InventoryController_SearchStockInventoryRecordTest extends TestCase
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
             $this->inventory=factory(InventoryAccount::class)->create();
             $this->inventoryMissions=InventoryAccountMission::create([
-                'inventory_id'=>$this->inventory['id'],
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>'A12-10-01',
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -76,7 +76,7 @@ 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();
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
         InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }

+ 2 - 2
tests/Inventory/http/InventoryAccountControllor/InventoryAccountController_StockInventoryTest.php

@@ -34,7 +34,7 @@ class InventoryControllerStockInventoryMissionTestTest extends TestCase
             DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
             $this->inventory=factory(InventoryAccount::class)->create();
             $this->inventoryMissions=InventoryAccountMission::create([
-                'inventory_id'=>$this->inventory['id'],
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>'A12-10-01',
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -84,7 +84,7 @@ 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();
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        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/model/InventoryAccountTest.php

@@ -23,7 +23,7 @@ class InventoryAccountTest extends TestCase
         $total=$this->inventory['total'];
         for ($i=0;$i<$total;$i++){
             $this->inventoryMissions=InventoryAccountMission::create([
-                'inventory_id'=>$this->inventory['id'],
+                'inventory_account_id'=>$this->inventory['id'],
                 'location'=>Str::random(5),
                 'commodity_id'=>256226,
                 'produced_at'=>null,
@@ -49,28 +49,28 @@ class InventoryAccountTest 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=InventoryAccountMission::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=InventoryAccountMission::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=InventoryAccountMission::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
     {
-        InventoryAccountMission::where('inventory_id',$this->inventory['id'])->delete();
+        InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
         InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }