Jelajahi Sumber

Merge branch 'zengjun'

# Conflicts:
#	app/Http/Controllers/TestController.php
zhouzhendong 4 tahun lalu
induk
melakukan
4b48677f64
1 mengubah file dengan 91 tambahan dan 44 penghapusan
  1. 91 44
      app/Http/Controllers/TestController.php

+ 91 - 44
app/Http/Controllers/TestController.php

@@ -8,7 +8,6 @@ use App\Commodity;
 use App\CommodityMaterialBoxModel;
 use App\Components\AsyncResponse;
 use App\Components\ErrorPush;
-use App\DeliveryAppointment;
 use App\ErrorTemp;
 use App\Feature;
 use App\Http\ApiControllers\LoginController;
@@ -19,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;
@@ -35,10 +39,8 @@ use App\OwnerFeeOperationDetail;
 use App\OwnerFeeStorage;
 use App\OwnerPriceOperation;
 use App\OrderPackageCountingRecord;
-use App\Process;
 use App\ProcurementCheckSheet;
 use App\RejectedBill;
-use App\RejectedBillItem;
 use App\Services\BatchService;
 use App\Services\CacheShelfService;
 use App\Services\ForeignHaiRoboticsService;
@@ -99,26 +101,72 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
-    public function test(){
-        dd(Carbon::now()->gt(Carbon::parse(date("Y-m-d")." ".explode("-",DeliveryAppointment::PERIOD[0])[1].":00:00")));
-        DB::beginTransaction();
-        try {
-            foreach (DB::connection("was_test")->table("processes")->where("created_at",">=","2021-09-11 11:00:00")
-                ->get() as $item){
-                $val = Process::query()->where("code",$item->code)->first();
-                if (!$val){
-                    unset($item->id);
 
-                    Process::query()->create((array)$item);
+    private function valFormat($val):?string
+    {
+        if ($val!==null){
+            $ret = date("Y-m-d H:i:s",strtotime($val))===(string)$val;
+            if ($ret)$val = "to_date('".$val."','yyyy-mm-dd hh24:mi:ss')";
+            else $val = "'".$val."'";
+        }else $val = "null";
+        return $val;
+    }
+
+    public function test1($task,$amount){
+        DB::connection("oracle")->beginTransaction();
+        try {
+            $columns = '';
+            $values = '';
+            foreach ($task as $key => $val) {
+                if (Str::upper($key) == 'TASKID_SEQUENCE') {
+                    $taskMax = DB::connection("oracle")->selectOne(DB::raw("select MAX(TASKID_SEQUENCE) maxseq from TSK_TASKLISTS where taskid = ?"), [$task->taskid]);
+                    $val = $taskMax->maxseq + 1;
+                }
+                if (Str::upper($key) == 'FMQTY' || Str::upper($key) == 'FMQTY_EACH'
+                    || Str::upper($key) == 'PLANTOQTY' || Str::upper($key) == 'PLANTOQTY_EACH') {
+                    $val -= $amount;
+                    $task->$key = $amount;
                 }
+                $columns .= $key . ",";
+                $values .= $this->valFormat($val) . ",";
             }
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            dd($e->getMessage());
+            $columns = mb_substr($columns, 0, -1);
+            $values = mb_substr($values, 0, -1);
+            $sql = <<<sql
+    INSERT INTO TSK_TASKLISTS({$columns}) VALUES({$values})
+sql;
+            dd($sql);
+        } catch (\Exception $e) {
+            dd($e);
         }
-        dd(1);
+    }
+
+    public function test()
+    {
+        $models = app("MaterialBoxModelService")->getModelSortedByOwner(null);
+        foreach ($models as $model){
+            $box = app("MaterialBoxService")->getAnEmptyBox($model,[],2);
+            dd($box);
+            if ($box)return $box;
+        }
+        dd();
         TaskTransaction::query()->where("id",">=",280)->delete();
+        /*$a= new StorageService();
+        $a->clearTask(["HAIB1-01-01"]);
+        $task = StationTaskMaterialBox::query()->find(90233);
+        $station = Station::query()->find(11);
+        $foreignHaiRoboticsService = new ForeignHaiRoboticsService();
+        $foreignHaiRoboticsService->putBinToStore_fromCacheShelf($task, $station);
+        dd(1);*/
+        /*$batchService = new BatchService();
+        $batches = Batch::query()->where("id",171829)->get();
+        $batchService->assignTasks($batches);
+        dd();*/
+        /*TaskTransaction::query()->where("id",">=",277)->delete();
+        StationTaskMaterialBox::query()->whereIn("id",[89685,89686,89687])->delete();
+        app("CacheShelfService")->_stationCacheLightOff("HAIB1-01-01");//灭灯
+        app("CacheShelfService")->_stationCacheLightOff("HAIB1-02-01");//灭灯
+        dd(1);*/
         Station::query()->where("station_type_id", 5)->update(["status" => 1]);
         Cache::forget("CACHE_SHELF_AVAILABLE");
         $station = ["HAIB1-01-01", "HAIB1-02-01"];
@@ -219,26 +267,6 @@ class TestController extends Controller
         }
     }
 
-    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);
@@ -333,11 +361,30 @@ sql;
             ]);
     }
 
-    public function sync_order_packages_where_exception_status_在途异常()
-    {
-//        $logistic_number = OrderPackage::query()->where('exception_status', 5)->pluck('logistic_number')->toArray();
-        /** @var OrderPackageReceivedSyncService $OrderPackageReceivedSyncService */
-        $OrderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
-        $OrderPackageReceivedSyncService->syncLogisticRoute(false, ['YT5786786410738']);
+    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];
     }
+
 }