haozi 5 years ago
parent
commit
dc5026a683

+ 4 - 9
app/LaborReport.php

@@ -55,10 +55,10 @@ class LaborReport extends Model
         return $this->hasOne('App\LaborReportStatus','labor_report_id','id')
             ->where('status','已退场');
     }
-    public function remarks(){
-        return $this->hasOne('App\Sign','signable_id','id')
-            ->where('field','remark')->where('signable_type','labor_reports');
-    }
+//    public function remarks(){
+//        return $this->hasOne('App\Sign','signable_id','id')
+//            ->where('field','remark')->where('signable_type','labor_reports');
+//    }
     public function getRoundCheckInAtAttribute(){
         if (!$this['check_in_at'])return null;
         $round_check_in_at=Carbon::parse($this['check_in_at'])->format('i');
@@ -73,11 +73,6 @@ class LaborReport extends Model
         if ($round_check_out_at>=25&&$round_check_out_at<=55) return Carbon::parse($this['check_out_at'])->clone()->setMinutes(30)->setSeconds(00)->format('Y-m-d H:i:s');
         if ($round_check_out_at>55&&$round_check_out_at<=59) return Carbon::parse($this['check_out_at'])->clone()->addHour()->setMinutes(00)->setSeconds(00)->format('Y-m-d H:i:s');
     }
-//    public function getRemarkAttribute(){
-////        $this->hasOne('App\Sign','signable_id','id')
-////            ->where('field','remark')->where('signable_type','labor_reports')->value('mark');
-//        return $this['remarks']?$this['remarks']['mark']:null;
-//    }
     public function getHasGroupVerifyRightAttribute(){
         if (!Gate::allows('人事管理-临时工报表')){return null; }
         if (Gate::allows('人事管理-临时工报表-管理全部组')){return true;}

+ 1 - 1
app/Services/LaborReportService.php

@@ -28,7 +28,7 @@ class LaborReportService
     private function conditionQuery(array $params){
         $user=Auth::user();
         $laborReports=LaborReport::query()
-            ->with(['user','userDutyCheck','userWorkgroup','laborCompany','laborReportStatus','已退场','未审核'])->orderBy('labor_reports.id','DESC');
+            ->with(['user','userDutyCheck','userWorkgroup.signs','laborCompany','已退场','未审核'])->orderBy('labor_reports.id','DESC');
         if (!($params["is_export"] ?? false)&&!($params['id']??null)){
             $laborReports = $laborReports->whereNotIn('labor_reports.enter_number',function ($builder)use($params){
                 $builder->select('enter_number')->from('labor_reports')

+ 2 - 2
app/Services/StoreItemService.php

@@ -104,7 +104,7 @@ Class StoreItemService
         $storeItems = $this->getByWms($asnDetails);
         $asnDetails_map = $dataHandlerService->dataHeader(['asnno', 'asnlineno', 'sku'], $asnDetails);
         $updateParams = [[
-            'id', 'store_id', 'asn_line_code', 'name', 'sku', 'barcode', 'amount', 'quality', 'status', 'created_at', 'updated_at'
+           /* 'id',*/ 'store_id', 'asn_line_code', 'name', 'sku', 'barcode', 'amount', 'quality', 'status', 'created_at', 'updated_at'
         ]];
         $delete_storeItems = [];
         foreach ($storeItems as $storeItem) {
@@ -124,7 +124,7 @@ Class StoreItemService
                 $storeItem->created_at != $asnDetail['addtime'] ||
                 $storeItem->updated_at != $asnDetail['edittime']) {
                 $updateParams[] = [
-                    'id' => $storeItem->id,
+                   /* 'id' => $storeItem->id,*/
                     'store_id' => $storeItem->store->id,
                     'asn_line_code' => $asnDetail['asnlineno'],
                     'name' => $asnDetail['skudescrc'],

+ 0 - 4
app/Services/StoreService.php

@@ -45,12 +45,8 @@ Class StoreService
     {
         /** @var OracleDocAsnHerderService $oracleDocAsnHerderService */
         $oracleDocAsnHerderService = app(OracleDocAsnHerderService::class);
-        var_dump('getWmsAsnOnStartDateCreate_start',Carbon::now());
         $asnHerders = $oracleDocAsnHerderService->getWmsAsnOnStartDateCreate($startDate);
-        var_dump('getWmsAsnOnStartDateCreate_end',Carbon::now());
-        var_dump('createStore_start',Carbon::now());
         $this->createStore($asnHerders);
-        var_dump('createStore_end',Carbon::now());
     }
 
     public function storeUpdateByWms($startDate)

+ 1 - 1
app/UserWorkgroup.php

@@ -20,7 +20,7 @@ class UserWorkgroup extends Model
         return $this->belongsTo('App\Warehouse','warehouse_id','id');
     }
     public  function signs(){
-        return $this->hasOne('App\Sign','signable_id','id');
+        return $this->belongsTo('App\Sign','signable_id','id');
     }
     public  function getTokenAttribute(){
         return md5($this['name'].Carbon::now()->format('Y-m-d'));

+ 3 - 0
laravel-echo-server.lock

@@ -0,0 +1,3 @@
+{
+	"process": 18648
+}

BIN
public/images/QRCodeIMG/4.png


+ 12 - 14
tests/Services/RejectedBillService/SyncLoadedStatusByAsnHeaderTest.php

@@ -6,6 +6,7 @@ namespace Tests\Services\RejectedBillService;
 
 use App\OracleDOCASNHeader;
 use App\Services\OwnerService;
+use App\Services\RejectedBillService;
 use App\Services\StoreItemService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
@@ -16,35 +17,32 @@ use Tests\TestCase;
 class SyncLoadedStatusByAsnHeaderTest extends TestCase
 {
     /**
-     * @var StoreService $service
-     * @var OwnerService $ownerService
-     * @var WarehouseService $warehouseService
+     * @var RejectedBillService $service
      *
      */
     public $service;
     public $asnHeaders;
-    public $asnHeadersEdit;
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
-        $this->service=app(StoreItemService::class);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
+        $this->service=app(RejectedBillService::class);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                 $query->with(['lineStatus', 'qualityStatus','basSku']);
             }])
             ->where('addTime', '>=', $startDate)
             ->get();
-        $this->asnHeadersEdit=OracleDOCASNHeader::query()
-            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
-                $query->with(['lineStatus', 'qualityStatus','basSku']);
-            }])
-            ->where('EditTime', '>=', $startDate)
-            ->whereColumn('EditTime', '<>', 'addTime')
-            ->get();
     }
     public function testSyncLoadedStatusByAsnHeaderTest(){
         if (empty($this->asnHeaders))return null;
+        $updateCollect=$this->service->getUpdateCollect($this->asnHeaders);
+        if ($updateCollect->isEmpty())return null;
+        $logisticNumberReturn=$this->service->getLogisticNumberReturn($updateCollect);
+        $rejectedBills=$this->service->getRejectedBills($logisticNumberReturn);
+        if ($rejectedBills->isEmpty())return null;
+        $this->assertNull($rejectedBills);
+        $this->service->syncLoadedStatusByAsnHerder($this->asnHeaders);
+        $this->assertNull($logisticNumberReturn);
     }
 }

+ 2 - 2
tests/Services/StoreItemService/GetAsnDetailsByAsnHerderTest.php

@@ -27,8 +27,7 @@ class GetAsnDetailsByAsnHerderTest extends TestCase
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
         $this->service=app(StoreItemService::class);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
@@ -45,6 +44,7 @@ class GetAsnDetailsByAsnHerderTest extends TestCase
             ->get();
     }
     public function testGetAsnDetailsByAsnHerder(){
+        ini_set('memory_limit','512M');
         if (empty($this->asnHeaders))return null;
         $asnDetails=$this->service->getAsnDetailsByAsnHerder($this->asnHeaders);
         $this->assertNotEmpty($asnDetails);

+ 3 - 4
tests/Services/StoreItemService/GetByWmsTest.php

@@ -26,8 +26,7 @@ class GetByWmsTest extends TestCase
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
         $this->service=app(StoreItemService::class);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
@@ -42,10 +41,10 @@ class GetByWmsTest extends TestCase
         $asnDetails=$this->service->getAsnDetailsByAsnHerder($this->asnHeaders);
         if(!$asnDetails){
             $storeItems=$this->service->getByWms($asnDetails);
-            $this->assertEmpty($storeItems);
+            $this->assertNull($storeItems);
         }else{
             $storeItems=$this->service->getByWms($asnDetails);
-            $this->assertNotEmpty($storeItems);
+            $this->assertNotNull($storeItems);
         }
 
     }

+ 1 - 2
tests/Services/StoreItemService/GetParamsByAsnDetailsTest.php

@@ -27,8 +27,7 @@ class GetParamsByAsnDetailsTest extends TestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $this->service=app(StoreItemService::class);
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->setSeconds(300);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
                 $query->with(['lineStatus', 'qualityStatus','basSku']);

+ 0 - 29
tests/Services/StoreService/AsnSyncTest.php

@@ -1,29 +0,0 @@
-<?php
-
-
-namespace Tests\AsnSync\Services;
-
-
-use App\Services\OracleDocAsnDetailService;
-use App\Services\OracleDocAsnHerderService;
-use App\Services\StoreService;
-use Carbon\Carbon;
-use Illuminate\Support\Facades\Auth;
-use Tests\TestCase;
-
-class AsnSyncTest extends TestCase
-{
-    /** @var OracleDocAsnDetailService $service */
-    public $service;
-    public function setUp(): void
-    {
-        $this->service  = app(OracleDocAsnDetailService::class);
-        parent::setUp(); // TODO: Change the autogenerated stub
-    }
-
-
-    public function testAsnSync(){
-        $startDate=Carbon::parse('2020-11-11 23:59:59')->subSeconds(65)->format('Y-m-d H:i:s');
-        app(StoreService::class)->syncWmsAsnData($startDate);
-    }
-}

+ 4 - 3
tests/Services/StoreService/CreateStoreTest.php

@@ -19,8 +19,7 @@ class CreateStoreTest extends TestCase
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
         $this->service=app(StoreService::class);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
@@ -31,8 +30,10 @@ class CreateStoreTest extends TestCase
     }
     public function testCreateStore(){
         if (!$this->asnHeaders) return null;
-        $this->stores=$this->service->createStore($this->asnHeaders);
+        $this->service->createStore($this->asnHeaders);
+        $this->stores=$this->service->getByWms($this->asnHeaders);
         $this->assertNotEmpty($this->stores);
+        $this->assertNotNull($this->asnHeaders);
     }
     public function tearDown(): void
     {

+ 1 - 2
tests/Services/StoreService/GetParamsByAsnHeaderTest.php

@@ -27,8 +27,7 @@ class GetParamsByAsnHeaderTest extends TestCase
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
         $this->service=app(StoreService::class);
         $this->ownerService=app(OwnerService::class);
         $this->warehouseService=app(WarehouseService::class);

+ 69 - 0
tests/Services/StoreService/SyncWmsAsnDataTest.php

@@ -0,0 +1,69 @@
+<?php
+
+
+namespace Tests\AsnSync\Services;
+
+
+use App\OracleDOCASNHeader;
+use App\Services\StoreService;
+use Illuminate\Support\Facades\DB;
+use Tests\TestCase;
+
+class SyncWmsAsnDataTest extends TestCase
+{
+    /** @var StoreService $service */
+    public $service;
+    public $asnHeaders;
+    public $asnHeadersEdit;
+    public $asnHeadersTotal;
+    public $startDate;
+    public $stores;
+    public function setUp(): void
+    {
+
+        parent::setUp(); // TODO: Change the autogenerated stub
+        $this->startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
+        $this->service = app(StoreService::class);
+        $this->asnHeaders = OracleDOCASNHeader::query()
+            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
+                $query->with(['lineStatus', 'qualityStatus', 'basSku']);
+            }])
+            ->where('addTime', '>=', $this->startDate)
+            ->get();
+        $this->asnHeadersEdit = OracleDOCASNHeader::query()
+            ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
+                $query->with(['lineStatus', 'qualityStatus', 'basSku']);
+            }])
+            ->where('EditTime', '>=', $this->startDate)
+            ->whereColumn('EditTime', '<>', 'addTime')
+            ->get();
+    }
+
+
+    public function testSyncWmsAsnData()
+    {
+          if (!$this->asnHeaders && !$this->asnHeadersEdit) return null;
+        if (!empty($this->asnHeadersEdit)){
+            foreach ($this->asnHeadersEdit as $asnHerder)
+                $this->asnHeaders->add($asnHerder);
+        }
+        if ($this->asnHeaders) {
+            $this->service->syncWmsAsnData($this->startDate);
+            $this->stores = $this->service->getByWms($this->asnHeaders);
+            $this->assertNotEmpty($this->stores);
+        } else {
+            $this->assertNull($this->asnHeaders);
+        }
+    }
+
+    public function tearDown(): void
+    {
+        $storeIds = [];
+        foreach ($this->stores as $store) {
+            array_push($storeIds, $store->id);
+        }
+        DB::table('stores')->whereIn('asn_code', data_get($this->asnHeaders, '*.asnno'))->delete();
+        DB::table('store_items')->whereIn('store_id', $storeIds)->delete();
+        parent::tearDown(); // TODO: Change the autogenerated stub
+    }
+}

+ 10 - 3
tests/Services/StoreService/UpdateStoreTest.php

@@ -19,8 +19,7 @@ class UpdateStoreTest extends TestCase
     public function setUp(): void
     {
         parent::setUp(); // TODO: Change the autogenerated stub
-        $dataInterval = intval(data_get(config('sync'), 'asn_sync.interval')) * 60 + 5;
-        $startDate = \Illuminate\Support\Carbon::now()->subSeconds($dataInterval);
+        $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
         $this->service=app(StoreService::class);
         $this->asnHeaders=OracleDOCASNHeader::query()
             ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
@@ -34,11 +33,19 @@ class UpdateStoreTest extends TestCase
         if (!$this->asnHeaders) {
             $this->assertNull($this->asnHeaders);
         }else{
-            //$this->assertEquals($this->service->updateStore($this->asnHeaders),1);
+            $this->service->updateStore($this->asnHeaders);
+            $this->stores=$this->service->getByWms($this->asnHeaders);
+            $this->assertNotEmpty($this->stores);
         }
     }
     public function tearDown(): void
     {
+        $storeIds=[];
+        foreach ($this->stores as $store){
+            array_push($storeIds,$store->id);
+        }
+        DB::table('stores')->whereIn('asn_code',data_get($this->asnHeaders,'*.asnno'))->delete();
+        DB::table('store_items')->whereIn('store_id',$storeIds)->delete();
         parent::tearDown(); // TODO: Change the autogenerated stub
     }
 }