ajun 4 лет назад
Родитель
Сommit
b14ae153ed
1 измененных файлов с 35 добавлено и 20 удалено
  1. 35 20
      app/Http/Controllers/TestController.php

+ 35 - 20
app/Http/Controllers/TestController.php

@@ -18,11 +18,16 @@ use App\Jobs\OrderCreateWaybill;
 use App\Jobs\SettlementBillReportTask;
 use App\Jobs\StoreCreateInstantBill;
 use App\Jobs\WeightUpdateInstantBill;
+use App\LaborReport;
+use App\LaborReportStatus;
 use App\MaterialBox;
 use App\MaterialBoxModel;
 use App\OracleDOCASNHeader;
 use App\OracleDOCOrderHeader;
+use App\OracleDocOrderPackingSummary;
 use App\Order;
+use App\OrderIssue;
+use App\OrderIssueProcessLog;
 use App\OrderPackage;
 use App\Owner;
 use App\OwnerFeeDetail;
@@ -96,6 +101,7 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
+
     private function valFormat($val):?string
     {
         if ($val!==null){
@@ -105,6 +111,7 @@ class TestController extends Controller
         }else $val = "null";
         return $val;
     }
+
     public function test1($task,$amount){
         DB::connection("oracle")->beginTransaction();
         try {
@@ -133,6 +140,7 @@ sql;
             dd($e);
         }
     }
+
     public function test()
     {
         $models = app("MaterialBoxModelService")->getModelSortedByOwner(null);
@@ -259,26 +267,6 @@ sql;
         }
     }
 
-    public function updateWorkOrder()
-    {
-        $items = WorkOrder::query()->with('order.owner')->get();
-        $params = [];
-        $items->each(function ($item) use (&$params) {
-            if ($item->order) {
-                $owner_id = $item->order->owner_id;
-
-                $params[] = [
-                    'id' => $item->id,
-                    'order_id' => $item->order->id,
-                    'owner_id' => $owner_id,
-                ];
-                $item->owner_id = $owner_id;
-                $item->save();
-            }
-        });
-    }
-
-
     public function testUpdateInv()
     {
         ini_set('max_execution_time', 0);
@@ -372,4 +360,31 @@ sql;
                 'status' => 7,
             ]);
     }
+
+    public function syncOrderPackage(){
+        ini_set('memory_limit','500M');
+        ini_set('max_execution_time', 0);
+        $orderPackingSummary = OracleDocOrderPackingSummary::query()
+            ->where('editTime','>=','2021-09-11 12:00:00')
+            ->where('editTime','<=','2021-09-12 12:40:00')
+            ->get();
+
+        $orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
+        foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
+            foreach ($orderPackingSummarys as $orderPackingSummary) {
+                $orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
+                $orderPackage->update([
+                    'uploaded_to_wms'=> true,
+                    'weight'=>$orderPackingSummary->grossweight,
+                    'length'=>$orderPackingSummary->length,
+                    'width'=>$orderPackingSummary->width,
+                    'height'=>$orderPackingSummary->height,
+                    'weighed_at'=>$orderPackingSummary->edittime
+                ]);
+                dispatch(new WeightUpdateInstantBill($orderPackage));
+            }
+        }
+        return ['success' => true];
+    }
+
 }