Forráskód Böngészése

Merge branch 'master' into zzd

# Conflicts:
#	app/Http/Controllers/TestController.php
zhouzhendong 4 éve
szülő
commit
acbbbdd72f

+ 9 - 12
app/Http/Controllers/WaveController.php

@@ -179,7 +179,7 @@ class WaveController extends Controller
             }
             $no = rtrim($no,',');
             $sql = <<<SQL
-SELECT WAVENO,COUNT(*) count from DOC_WAVE_DETAILS WHERE WAVENO IN ({$no}) GROUP BY WAVENO
+SELECT WAVENO,MAX(SEQNO) count from DOC_WAVE_DETAILS WHERE WAVENO IN ({$no}) GROUP BY WAVENO
 SQL;
             foreach (DB::connection("oracle")->select(DB::raw($sql)) as $wave){
                 Batch::query()->where("code",$wave->waveno)->update(["split_size" => (int)ceil($wave->count/$splitNumber)]);
@@ -193,10 +193,12 @@ SQL;
         $codes = \request("codes",[]);
         if (!$codes)$this->error("无记录");
         $batches = [];
-        foreach (Batch::query()->select("code","split_size")->withCount("orders")
+        foreach (Batch::query()->select("code","split_size","id")
                      ->whereIn("code",$codes)->whereNotNull("split_size")->get() as $batch){
             if ($batch->orders_count==0)continue;
-            $batches[$batch->code] = (int)ceil($batch->orders_count/$batch->split_size);
+            $bin = OrderBin::query()->selectRaw("MAX(number) max")->whereIn("order_id",Order::query()
+                ->select("id")->where("batch_id",$batch->id))->first();
+            $batches[$batch->code] = (int)ceil($bin->max/$batch->split_size);
         }
         $this->success($batches);
     }
@@ -212,7 +214,7 @@ SQL;
         $batch = null;
         if (!$code || !$batch = Batch::query()->select("id","split_size")->where("code",$code)->first())$this->error("无记录");
         $sql = <<<SQL
-SELECT a.ORDERNO,a.QTY,s.ALTERNATE_SKU1,a.LOCATION FROM ACT_ALLOCATION_DETAILS a
+SELECT a.ORDERNO,a.QTY,s.ALTERNATE_SKU1,a.LOCATION,w.SEQNO FROM ACT_ALLOCATION_DETAILS a
     LEFT JOIN DOC_ORDER_HEADER o ON a.ORDERNO = o.ORDERNO
     LEFT JOIN DOC_WAVE_DETAILS w ON o.ORDERNO = w.ORDERNO
     LEFT JOIN BAS_SKU s ON a.SKU = s.SKU
@@ -221,16 +223,11 @@ SQL;
         $orders = DB::connection("oracle")->select(DB::raw($sql));
         $result = [];
         $currentList = [];
-        $slowPointer = 0;
         $nodeSign = "";
         foreach ($orders as $order){
-            if ($order->orderno!=$nodeSign){
-                if ($slowPointer==$batch->split_size){
-                    $result[] = $currentList;
-                    $currentList = [];
-                    $slowPointer = 0;
-                }
-                $slowPointer++;
+            if ($order->seqno%$batch->split_size==0 && $nodeSign!=$order->orderno){
+                $result[] = $currentList;
+                $currentList = [];
                 $nodeSign = $order->orderno;
             }
             $currentList[] = ["barcode"=>$order->alternate_sku1,"qty"=>$order->qty,"location"=>$order->location];

+ 9 - 12
app/Http/Controllers/api/thirdPart/haochuang/SortingController.php

@@ -95,28 +95,25 @@ class SortingController extends Controller
             $start = (($childIndex-1)*$batch->split_size)+1;
             $end = $childIndex*$batch->split_size;
             $sql = <<<SQL
-SELECT ORDERNO
-FROM (SELECT T.ORDERNO, ROWNUM AS NO
-FROM (SELECT ORDERNO FROM DOC_WAVE_DETAILS WHERE WAVENO = '{$batch_id}' ORDER BY SEQNO) T)
-WHERE NO BETWEEN {$start} AND {$end}
+SELECT ORDERNO FROM DOC_WAVE_DETAILS WHERE WAVENO = '{$batch_id}' AND SEQNO BETWEEN {$start} AND {$end};
 SQL;
             $waves = DB::connection("oracle")->select(DB::raw($sql));
             $codes = array_column($waves,'orderno');
-            $orders = Order::query()->whereIn("code",$codes)->get();
-        }else $orders = $batch->orders()->get();
+            $orders = Order::query()->with(["bin","owner","orderCommodities.commodity.barcodes"])->whereIn("code",$codes)->get();
+        }else $orders = $batch->orders()->with(["bin","owner","orderCommodities.commodity.barcodes"])->get();
 
         $ordersSorted=$orders->sortBy(function(Order $order){
-            return $order->bin()->first()['number'];
+            return $order->bin->number;
         });
         $ordersSorted->each(function(Order $order)use(&$data,$request,$childIndex,$batch){
             if($order['status']=='取消')return;
             $orderData=[
                 'order_id'=>$order['code'],
-                'owner'=>$order->owner()->first()['code'],
+                'owner'=>$order->owner->code,
                 'status'=>$order['status']=='未处理'?'available':$order['status'],
                 'created_at'=>$order['created_at']->toDateTimeString(),
                 'bin'=>(function()use($order,$childIndex,$batch){
-                    $bin=$order->bin()->first()['number']??'';
+                    $bin=$order->bin->number??'';
                     if(!$bin){
                         $bin=OracleDOCWaveDetails::query()->where('orderno', 'SO201230003574')->get('seqno')->first()['seqno']??'';
                         LogService::log(__METHOD__,__FUNCTION__,'bin缺失补查:'.$bin.'. order:'.$order->toJson());
@@ -126,13 +123,13 @@ SQL;
                 })(),
                 'barcodes'=>[]
             ];
-            $order->orderCommodities()->each(function(OrderCommodity $orderCommodity)use(&$orderData,$request){
-                $commodity=$orderCommodity->commodity()->first();
+            $order->orderCommodities->each(function(OrderCommodity $orderCommodity)use(&$orderData,$request){
+                $commodity=$orderCommodity->commodity;
                 if(!$commodity){
                     app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, '播种位数据准备出错,找不到订单对应的Commodity id的对象'.$orderCommodity['commodity_id'].',是否表数据在波次生成后丢失?'.json_encode($request->all()));
                     return;
                 }
-                $barcodeStr=$commodity->barcodes()->get()->map(function(CommodityBarcode $barcode){
+                $barcodeStr=$commodity->barcodes->map(function(CommodityBarcode $barcode){
                     return $barcode['code'];
                 })->filter(function($code){
                     return $code&&(!preg_match('/[\x{4e00}-\x{9fa5}]/u',$code));

+ 1 - 1
app/Services/HandInStorageService.php

@@ -453,7 +453,7 @@ sql;
      * @throws \Throwable
      * flux手持端 上架
      */
-    public function fluxHandPa(array $info, array $taskParam): bool
+    public function fluxHandPa(array $info, array $taskParam)
     {
         $tasks = $this->selectFluxTask($taskParam, $info['amount']);
         if (!$tasks) return false; //获取任务失败

+ 2 - 2
app/Services/OwnerService.php

@@ -124,8 +124,8 @@ class OwnerService implements UserFilter
     }
 
     public function firstOrCreate(array $params, array $values = null){
-        if (!$values) return Owner::query()->firstOrCreate($params);
-        return Owner::query()->firstOrCreate($params,$values);
+        if (!$values) return Owner::query()->whereNull("deleted_at")->firstOrCreate($params);
+        return Owner::query()->whereNull("deleted_at")->firstOrCreate($params,$values);
     }
 
 

+ 51 - 16
app/Services/ReplenishmentService.php

@@ -55,7 +55,9 @@ sql;
     public function getEaInventoryByCustomerAndSku($customer,array $skuArr): array
     {
         $db = DB::connection("oracle");
-        $sql = <<<sql
+        $info=array();
+        foreach (array_chunk($skuArr,1000) as $item){
+            $sql = <<<sql
 select INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,sum(INV_LOT_LOC_ID.QTY) qty
 from INV_LOT_LOC_ID
          left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
@@ -63,9 +65,9 @@ where BAS_LOCATION.LOCATIONUSAGE = 'EA'
   AND customerid = ?
 
 sql;
-        if (count($skuArr) > 0) {
+        if (count($item) > 0) {
             $sql .= " and sku in (";
-            foreach ($skuArr as $index => $str) {
+            foreach ($item as $index => $str) {
                 if ($index == 0) {
                     $sql .= "'" . $str . "'";
                     continue;
@@ -74,8 +76,10 @@ sql;
             }
             $sql .= ")";
         }
-        $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID';
-        $info= $db->select(DB::raw($sql),[$customer]);
+            $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID';
+            $info[]= $db->select(DB::raw($sql),[$customer]);
+        }
+        $info = array_merge(...$info);
         //整合同sku下的拣货库位
         $tmpArray = array();
         foreach ($info as $row) {
@@ -108,26 +112,30 @@ sql;
     public function getRsInventoryByCustomerAndSku($customer,array $skuArr): array
     {
         $db = DB::connection("oracle");
-        $sql = <<<sql
+        $info=array();
+        foreach (array_chunk($skuArr,1000) as $item){
+            $sql = <<<sql
 select INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM,sum(INV_LOT_LOC_ID.QTY) qty
 from INV_LOT_LOC_ID
          left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
 where BAS_LOCATION.LOCATIONUSAGE = 'RS'
   AND customerid = ?
 sql;
-        if (count($skuArr) > 0) {
-            $sql .= " and sku in (";
-            foreach ($skuArr as $index => $str) {
-                if ($index == 0) {
-                    $sql .= "'" . $str . "'";
-                    continue;
+            if (count($item) > 0) {
+                $sql .= " and sku in (";
+                foreach ($item as $index => $str) {
+                    if ($index == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
                 }
-                $sql .= ",'" . $str . "'";
+                $sql .= ")";
             }
-            $sql .= ")";
+            $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM order by qty desc';
+            $info[]= $db->select(DB::raw($sql),[$customer]);
         }
-        $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM order by qty desc';
-        $info= $db->select(DB::raw($sql),[$customer]);
+        $info=array_merge(...$info);
         //整合同sku下的存储库位
         $tmpArray = array();
         foreach ($info as $row) {
@@ -146,4 +154,31 @@ sql;
         }
         return $tmpArray;
     }
+
+    public function combinationSql(array $skuArr,$sql)
+    {
+        foreach (array_chunk($skuArr,1000) as $index=>$item){
+            if ($index==0){
+                $sql .= " and sku in (";
+                foreach ($item as $i => $str) {
+                    if ($i == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
+                }
+            }else{
+                $sql .= " or sku in (";
+                foreach ($item as $a => $str) {
+                    if ($a == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
+                }
+            }
+            $sql .= ")";
+        }
+        return $sql;
+    }
 }

+ 1 - 1
resources/views/personnel/laborReport/index.blade.php

@@ -326,7 +326,7 @@
                     if(tokenOfBroadcastEnterAndLeave){
                         Echo.channel('{{$laravelEchoPrefix}}'+tokenOfBroadcastEnterAndLeave).listen('ImportEvent',(e)=>{
                             let labor=e.laborReport;
-                            laborReports.push(labor);
+                            laborReports.unshift(labor);
 
                             // setTimeout(function () {
                             //     window.location.reload();