ソースを参照

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

LD 5 年 前
コミット
2f9b647e3e

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

@@ -204,8 +204,9 @@ class StoreController extends Controller
         $items = [];
         $toDay = Carbon::now()->toDateTimeString();
         $depositories = [];
+        $traceId = microtime(true).Str::random(5);
         foreach ($details as $detail) {
-            $result = $this->executeSP($detail,$asnno,$depository_code,$db,$quality,$conn,$sql_sp);
+            $result = $this->executeSP($detail,$asnno,$depository_code,$db,$quality,$conn,$sql_sp,$traceId);
             if (substr($result, 0, 3) != '000') {
                 oci_close($conn);
                 app('LogService')->log(__METHOD__,"快速入库-FLUX收货失败","ASNNO:".$asnno.";ERROR:".$result);
@@ -247,13 +248,13 @@ class StoreController extends Controller
         return ['success'=>true,"data"=>"已成功将“".$asnno."”入库"];
     }
 
-    private function executeSP($detail, $asnno, $depository_code, $db, $quality, $conn, $sql_sp){
+    private function executeSP($detail, $asnno, $depository_code, $db, $quality, $conn, $sql_sp,$traceId){
         $IN_Warehouse = $detail->warehouseid ?? '';
         $In_Process_Action = '3';
         $In_ASNNo_C = $detail->asnno ?? '';
         $In_ASNLineNo_C = $detail->asnlineno ?? '';
         $In_FMTraceID_C = '';
-        $In_New_TraceID_C = microtime(true).Str::random(5);
+        $In_New_TraceID_C = $traceId;
         $In_ProductStatus = '00';
         $In_ProductStatus_Descr = '正常';
         $In_HoldRejectCode_C = 'OK';

+ 6 - 1
app/Http/Controllers/TestController.php

@@ -90,7 +90,12 @@ class TestController extends Controller
         }
     }
     public function test4(){
-        dd(strlen(microtime(true).Str::random(5)));
+        $a = DB::connection("oracle")->select(DB::raw("select CUSTOMERID,sku from doc_asn_details where asnno = 'ASN2011191431'"));
+        $b = array_column($a,"sku");
+        foreach ($b as &$n){
+            $n = "'".$n."'";
+        }
+        dd(implode(",",$b));
         $model1 = factory(Feature::class,2)->create([[
             "type" => "商品名称",
             "logic" => "包含",

+ 10 - 14
tests/Services/CustomerTest.php

@@ -17,20 +17,18 @@ class CustomerTest extends TestCase
     {
         parent::setUp();
         $this->service = app(CustomerService::class);
-        $this->data = factory(Customer::class,3)->create()->toArray();
+        $this->data = [
+            "models"=>factory(Customer::class,3)->create()->toArray()
+        ];
     }
 
-    public function create(){
+    public function testCreate(){
         $model = $this->service->create([
             "code" => date('Ymd').Str::random(4),
             "name" => date('Ymd').Str::random(5),
             "company_name" => date('Ymd').Str::random(6),
         ]);
         $this->assertNotNull($model);
-        $this->data[] = $model;
-        $this->assertEquals($model->code,$this->data["model"]["code"]);
-        $this->assertEquals($model->name,$this->data["model"]["name"]);
-        $this->assertEquals($model->company_name,$this->data["model"]["company_name"]);
     }
     public function testGetSelection(){
         $models = $this->service->getSelection(["id","name","company_name"]);
@@ -43,30 +41,28 @@ class CustomerTest extends TestCase
         $this->assertLessThanOrEqual(5,count($models));
     }
     public function testFind(){
-        $model = $this->service->find($this->data["model"]["id"]);
+        $model = $this->service->find($this->data["models"][0]["id"]);
         $this->assertNotNull($model);
     }
     public function testUpdate()
     {
         $value = date('YmdH').Str::random(4);
-        $row = $this->service->update(["id"=>$this->data[0]["id"]],[
+        $row = $this->service->update(["id"=>$this->data["models"][0]["id"]],[
             "name" => $value,
         ]);
-        $this->data["model"]["name"] = $value;
+        $this->data["models"][0]["name"] = $value;
         $this->assertEquals($row,1);
     }
     public function testDestroy()
     {
-        $row = $this->service->destroy($this->data[0]["id"]);
+        $row = $this->service->destroy($this->data["models"][0]["id"]);
         $this->assertEquals($row,1);
-        $this->assertDeleted("customers", $this->data["model"]);
+        $this->assertDeleted("customers", $this->data["models"][0]);
     }
 
     public function tearDown(): void
     {
+        Customer::destroy(array_column($this->data["models"],'id'));
         parent::tearDown();
-        $ids = array_column($this->data,'id');
-        $row = Customer::destroy($ids);
-        $this->assertGreaterThan(0,$row);
     }
 }

+ 10 - 43
tests/Services/FeatureServiceTest.php

@@ -17,65 +17,26 @@ class FeatureServiceTest extends TestCase
         parent::setUp();
         $this->service = app(FeatureService::class);
         $this->data = [
-            [
-                "type" => "商品名称",
-                "logic" => "包含",
-                "describe"=>"衣服",
-            ],[
-                "type" => "订单类型",
-                "logic" => "不包含",
-                "describe"=>"创建",
-            ],[
-                "type" => "承运商",
-                "logic" => "等于",
-                "describe"=>"顺丰",
-            ],[
-                "type" => "店铺类型",
-                "logic" => "不包含",
-                "describe"=>"日用品",
-            ],[
-                "type" => "商品名称",
-                "logic" => "不包含",
-                "describe"=>"鞋子",
-            ],[
-                "type" => "订单类型",
-                "logic" => "包含",
-                "describe"=>"取消",
-            ],[
-                "type" => "商品名称",
-                "logic" => "包含",
-                "describe"=>"测试",
-            ],[
-                "type" => "订单类型",
-                "logic" => "不包含",
-                "describe"=>"实际",
-            ],[
-                "type" => "店铺类型",
-                "logic" => "等于",
-                "describe"=>"测试",
-            ]
+           "models" => factory(Feature::class,3)->create()->toArray(),
         ];
     }
 
     public function testGetMapArray(){
-        factory(Feature::class,3)->create();
         $models = $this->service->getMapArray();
         $this->assertGreaterThanOrEqual(3,count($models));
     }
     public function testTranslationFeature(){
-        $model1 = factory(Feature::class)->create($this->data[0]);
-        $model2 = factory(Feature::class)->create($this->data[1]);
-        $model3 = factory(Feature::class)->create($this->data[2]);
-        $str = $model1->id."&(".$model2->id."|".$model3->id.")";
+        $str = $this->data["models"][0]["id"]."&(".$this->data["models"][1]["id"]."|".$this->data["models"][2]["id"].")";
         $result = $this->service->translationFeature($str);
         $this->assertEquals(3,count($result));
-        $this->assertEquals("订单类型",$result[1]["type"]);
+        $this->assertEquals($this->data["models"][1]["type"],$result[1]["type"]);
         $this->assertEquals(false,$result[0]["strategyGroupStartSign"]);
         $this->assertEquals(true,$result[1]["strategyGroupStartSign"]);
         $this->assertEquals("并且",$result[1]["calculation"]);
         $this->assertEquals(true,$result[2]["strategyGroupEndSign"]);
         $this->assertEquals("或",$result[2]["calculation"]);
     }
+    //TODO 标记
     public function testAnalysisFeature(){
         $model1 = factory(Feature::class)->create($this->data[4]);
         $model2 = factory(Feature::class)->create($this->data[5]);
@@ -143,4 +104,10 @@ class FeatureServiceTest extends TestCase
         $feature = Feature::query()->get();
         $this->assertCount(0,$feature);
     }
+
+    public function tearDown(): void
+    {
+        Feature::destroy(array_column($this->data["models"],"id"));
+        parent::tearDown();
+    }
 }