Przeglądaj źródła

入库同步更新修复数据及调整

haozi 4 lat temu
rodzic
commit
b746962c5b

+ 1 - 0
app/Console/Commands/WasSyncWmsAsnInformation.php

@@ -84,6 +84,7 @@ class WasSyncWmsAsnInformation extends Command
     public function WasSyncWmsAsn(){
         /** @var StoreService $storeService */
         $storeService  = app(StoreService::class);
+        ini_set('memory_limit', '1024M');
         $storeService->storeCreateByWms();
         $storeService->storeUpdateByWms();
     }

+ 29 - 8
app/Http/Controllers/TestController.php

@@ -61,6 +61,7 @@ use App\Station;
 use App\StationTask;
 use App\StationTaskMaterialBox;
 use App\Store;
+use App\StoreItem;
 use App\TaskTransaction;
 use App\Unit;
 use App\User;
@@ -419,15 +420,16 @@ sql;
         ini_set('max_execution_time', 0);
         ini_set('memory_limit', '1024M');
         $now = Carbon::now();
-        $startDate = $this->getDate();
-        $diffDay = 16; // 天数
+//        $startDate = $this->getDate();
+        $startDate = '2021-09-19 14:15:58';
+        $diffDay = 2; // 天数
         for($i = 0;$i<=$diffDay;$i++){
-            $endDate = Carbon::parse($startDate)->addHours(1)->toDateTimeString();
-//            $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
-//            if (count($doc_asn_headers)>0){
-//                $this->syncStores($doc_asn_headers);
-//                $this->syncDate($endDate);
-//            }
+            $endDate = Carbon::parse($startDate)->addDays(1)->toDateTimeString();
+            $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
+            if (count($doc_asn_headers)>0){
+                $this->syncStores($doc_asn_headers);
+                $this->syncDate($endDate);
+            }
             dump($endDate);
             $startDate = $endDate;
         }
@@ -485,4 +487,23 @@ sql;
         // 清空保存 ans  号的栈
         // 清除 更新时间 开始 结束
     }
+
+    public function updateStoreItem()
+    {
+        $storeIds=Store::query()
+            ->where('updated_at','>=','2021-09-19 14:15:58')
+            ->whereColumn('updated_at','<>','created_at')
+            ->pluck('id');
+
+        $storeItemMaxIds=StoreItem::query()
+            ->selectRaw('max(id) as max_id')
+            ->whereIn('store_id',$storeIds)
+            ->groupBy(['store_id','asn_line_code'])
+            ->get();
+        $storeItems=StoreItem::query()
+            ->whereIn('store_id',$storeIds)
+            ->whereNotIn('id',$storeItemMaxIds)
+            ->delete();
+
+    }
 }

+ 1 - 1
app/Store.php

@@ -16,7 +16,7 @@ class Store extends Model
     use SoftDeletes;
 
     protected $fillable=[
-        'asn_code','warehouse_id','owner_id','stored_method','status','remark','deleted_at','is_fast_stored'
+        'asn_code','warehouse_id','owner_id','stored_method','status','remark','deleted_at','is_fast_stored','updated_at','created_at'
     ];
 
     public function owner(){