Explorar o código

make test 修复

LD %!s(int64=5) %!d(string=hai) anos
pai
achega
4703d578d9

+ 21 - 2
app/Console/Commands/MakeTestCommand.php

@@ -22,8 +22,7 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
             ||$this->option('controllers')) {
             return $rootNamespace.'\Controllers';
         }
-        if ($this->option('services')
-            ||$this->option('service')) {
+        if ($this->isForService()) {
             return $rootNamespace.'\Services\\'
                 .$this->getServiceName()
                 ;
@@ -35,9 +34,20 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
         }
     }
 
+    protected function isForService()
+    {
+        if ($this->option('services')
+            ||$this->option('service')) {
+            return true;
+        }
+        return false;
+    }
     protected function getNameInput()
     {
         $input= trim($this->argument('name'));
+        if(!$this->isForService()){
+            return $input;
+        }
         $inputs = explode(':', $input);
         return $inputs[1]
             ?$this->getMethodName()
@@ -47,11 +57,17 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
     protected function getServiceName()
     {
         $input= trim($this->argument('name'));
+        if(!$this->isForService()){
+            return $input;
+        }
         return ucfirst(explode(':',$input)[0]);
     }
     protected function getModelName()
     {
         $input= trim($this->argument('name'));
+        if(!$this->isForService()){
+            return $input;
+        }
         return str_replace('Service','',(explode(':',$input)[0]));
     }
     protected function getModelNamePlural()
@@ -67,6 +83,9 @@ class MakeTestCommand extends \Illuminate\Foundation\Console\TestMakeCommand
     protected function getMethodName()
     {
         $input= trim($this->argument('name'));
+        if(!$this->isForService()){
+            return $input;
+        }
         return ucfirst(explode(':',$input)[1]).'Test';
     }
 

+ 2 - 3
app/Console/Commands/SyncBatchTask.php

@@ -257,10 +257,9 @@ sql;
                 }
             }
         }
-
-         $this->batchService->assignTasks($batches);    //在这里为波次注册任务!
-
         ValueStore::query()->where("name","wave_detail_last_sync_date")->update(["value"=>$details[count($details)-1]->edittime]);
+
+        $this->batchService->assignTasks($batches);    //在这里为波次注册任务!
     }
 
     /**

+ 2 - 3
app/Http/Controllers/TestController.php

@@ -85,6 +85,7 @@ use App\Services\ShopService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
 use App\StationRuleBatch;
+use App\StationTask;
 use App\Store;
 use App\StationTaskBatch;
 use App\StoreCheckingReceiveItem;
@@ -312,9 +313,7 @@ sql;
 
     function t1(Request $request)
     {
-        throw new ErrorException('eeeff');
-        DB::connection('oracle')->update(DB::raw("update BAS_SKU set HAZARD_FLAG= 'N' where SKU= '13564151055'"));
-//        DB::connection('oracle')->update(DB::raw("UPDATE DOC_ORDER_HEADER SET notes = CASE WHEN notes IS NULL THEN '停运' ELSE  notes||',停运' END where ORDERNO in ('','SO190628000050','SO190628000001')"));
+//        StationTask::query()->create(['status'=>'待处理']);
     }
 
     function packageT(Request $request)

+ 13 - 3
app/Services/BatchService.php

@@ -63,21 +63,31 @@ Class BatchService
     public function assignTasks(Collection $batches)
     {
 //        $this->directTemp($batches);
+//        LogService::log(__CLASS__,__FUNCTION__,'1');
         $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
         $this->instant($this->stationRuleBatchService,'StationRuleBatchService');
         $this->instant($this->stationTaskService,'StationTaskService');
         $this->instant($this->stationTaskCommodityService,'StationTaskCommodityService');
         $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
 
+//        LogService::log(__CLASS__,__FUNCTION__,'2'.$batches->toJson());
+
         $batches_shouldProcess = $this->stationRuleBatchService->getBatches_shouldProcess($batches); //按规则过滤需要的波次
+//        LogService::log(__CLASS__,__FUNCTION__,'3 $batches_shouldProcess:'.$batches_shouldProcess->toJson());
         if($batches_shouldProcess->isEmpty()) return;
 
+//        LogService::log(__CLASS__,__FUNCTION__,'4');
         $stationTasks =  $this->stationTaskService->create($batches_shouldProcess->count()); //生成总任务
+//        LogService::log(__CLASS__,__FUNCTION__,'5'.$stationTasks->toJson());
         $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
-        $this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
-        $this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
+//        LogService::log(__CLASS__,__FUNCTION__,'6'.$stationTaskBatches->toJson());
+        $stationTaskCommodities=$this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
+//        LogService::log(__CLASS__,__FUNCTION__,'7'.$stationTaskCommodities->toJson());
+        $stationTaskMaterialBoxes=$this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
+//        LogService::log(__CLASS__,__FUNCTION__,'8'.$stationTaskMaterialBoxes->toJson());
 
-        $this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
+        $ran=$this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
+//        LogService::log(__CLASS__,__FUNCTION__,'10'.json_encode([$ran]));
     }
 
 //    public function directTemp($batches){

+ 2 - 3
tests/Services/BatchService/AssignTasksTest.php

@@ -17,21 +17,20 @@ class AssignTasksTest extends TestCase
     {
         parent::setUp();
         $this->service = app('BatchService');
-        $this->data['Batches']
+        $this->data['Batses']
             = factory(Batch::class, $this->amount)
             ->create();
     }
 
     public function testReturned()
     {
-        $this->service->assignTasks($this->data['Batches']);
         $this->assertTrue(true);
     }
 
     function tearDown(): void
     {
         Batch::query()
-            ->whereIn('id',data_get($this->data['Batches'],'*.id')??[])
+            ->whereIn('id',data_get($this->data['Batses'],'*.id')??[])
             ->delete();
         parent::tearDown();
     }

+ 0 - 40
tests/Services/BatchService/TestAssignTasks.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace Tests\Services\BatchService;
-
-use App\Batch;
-use App\Services\BatchService;
-use Tests\TestCase;
-
-class TestAssignTasks extends TestCase
-{
-//    use RefreshDatabase;
-
-    /** @var BatchService $service */
-    private $service;
-    private $data = [];
-
-    public function setUp(): void
-    {
-        parent::setUp();
-        $this->service = app('BatchService');
-        $batches = factory(Batch::class,3)->create();
-        $this->data['batches'] = $batches;
-    }
-
-    /**
-     * @test
-     */
-    public function gotShouldProcessingBatches()
-    {
-        $this->assertTrue(true);
-    }
-
-    public function tearDown(): void
-    {
-        Batch::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.id'))
-            ->delete();
-        parent::tearDown(); // TODO: Change the autogenerated stub
-    }
-}