Преглед изворни кода

暂时开启了富勒下发波次接口

LD пре 5 година
родитељ
комит
e2dfb89659

+ 2 - 2
app/Http/Controllers/TestController.php

@@ -1112,7 +1112,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
 
 
     public function reNewBatches3()
     public function reNewBatches3()
     {
     {
-        $batches = Batch::query()->where('id','>', 79628)->get('code');
+        $batches = Batch::query()->where('id','>', 82182)->get('code');
         $batchCodes = $batches->map(function ($batch) {
         $batchCodes = $batches->map(function ($batch) {
             return $batch['code'];
             return $batch['code'];
         })->toArray();
         })->toArray();
@@ -1138,7 +1138,7 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
 //        dd($logs);
 //        dd($logs);
         foreach ($batchCodes as $code) {
         foreach ($batchCodes as $code) {
 //            $request=Cache::get('temp'.$code)['description'];
 //            $request=Cache::get('temp'.$code)['description'];
-            $request = Log::query()->select('description')->where('CREATED_AT', '>', '2021-01-22')
+            $request = Log::query()->select('description')->where('CREATED_AT', '>', '2021-02-25')
                 ->where('method', "issued_newBatch")
                 ->where('method', "issued_newBatch")
                 ->where('description', 'like', "%{$code}%")
                 ->where('description', 'like', "%{$code}%")
                 ->first();
                 ->first();

+ 78 - 78
app/Http/Controllers/api/thirdPart/flux/SortingController.php

@@ -30,85 +30,85 @@ class SortingController extends Controller
      */
      */
     public function newBatch(Request $request)
     public function newBatch(Request $request)
     {
     {
-//       $requestArr=$request->all();
+       $requestArr=$request->all();
         app('LogService')->log(__METHOD__, 'issued_' . __FUNCTION__, json_encode($request->all()));
         app('LogService')->log(__METHOD__, 'issued_' . __FUNCTION__, json_encode($request->all()));
-//        !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
-//        $errors=$this->newBatchValidator($requestArr)->errors();
-//        if(count($errors)>0){
-//            app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
-//            return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
-//                'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
-//        }
-//        $requestBatches = $requestArr['request']?? '';
-//
-//        foreach ($requestBatches as $requestBatch){
-//            $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
-//            $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
-//
-//            if(!$batch)$batch=new Batch();
-//            $batch->fill([
-//                    'code' => $requestBatch['waveno'],
-//                    'wms_type' => $requestBatch['batch_type']??'',
-//                    'wms_status' => $requestBatch['docstatus']??'',
-//                    'status' => '未处理',
-//                    'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
-//            ]);
-//            $batch->save();
-//            $oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
-//            foreach($requestBatch['order_list'] as $requestOrder){
-//                $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
-//                $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
-//                if(!$order){
-//                    $order=app("OrderService")->createOrder([
-//                        'batch_id' => $batch['id'],
-//                        'code' => $requestOrder['docno'],
-//                        'owner_id' => $owner['id'],
-//                        'wms_status' => $requestOrder['docstatus']??'波次下发',
-//                        'status' => '未处理',
-//                    ]);
-//                    app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
-//                }else{
-//                    $order['batch_id']= $batch['id'] ;
-//                    $order['owner_id']=$order['owner_id']??$owner['owner_id'];
-//                    $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
-//                    $order['status']=$order['status']??'未处理';
-//                }
-//                $order->save();
-//                OrderBin::query()->firstOrCreate([
-//                    'order_id' => $order['id'],
-//                    'number' => $requestOrder['reservedfield01'],
-//                ]);
-//                foreach($requestOrder['barcode_list'] as $requestBarcode){
-//                    $orderCommodity=OrderCommodity::query()
-//                        ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
-//                    if(!$orderCommodity){
-//                        /** @var CommodityService $commodityService */
-//                        $commodityService=app('CommodityService');
-//                        $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
-//                        $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
-//                        if(!$orderCommodity){
-//                            $orderCommodity = new OrderCommodity([
-//                                'order_id' => $order['id'],
-//                                'commodity_id' => $commodity['id'],
-//                                'amount' => $requestBarcode['fmqty_each']??0,
-//                                'wms_ptltaskid' => $requestBarcode['ptltaskid'],
-//                            ]);
-//                        }else{
-//                            $orderCommodity['order_id']=$order['id'];
-//                            $orderCommodity['commodity_id']=$commodity['id'];
-//                            $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
-//                            $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
-//                        }
-//                        $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
-//                        if($allocation)
-//                            $orderCommodity['location'] = $allocation['location'];
-//                        $orderCommodity->save();
-//                    }
-//                }
-//            }
-//        }
-//        return response()->json(['Response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000',
-//            'returnDesc'=>'消息处理成功:Success','resultInfo'=>'']]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+        !$requestArr?$requestArr=json_decode($request->getContent(),true):false;
+        $errors=$this->newBatchValidator($requestArr)->errors();
+        if(count($errors)>0){
+            app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, 'fields wrong, see Errors report please.'.'|'.json_encode($request->all()).'|'.json_encode($errors));
+            return response()->json(['Response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001',
+                'returnDesc'=>':Failure','resultInfo'=>'','errors'=>$errors]]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+        }
+        $requestBatches = $requestArr['request']?? '';
+
+        foreach ($requestBatches as $requestBatch){
+            $requestBatch['edittime']&&strpos(trim($requestBatch['edittime']),' ')?$editTimeFormat='Y-m-d H:i:s':$editTimeFormat='YmdHis';
+            $batch=Batch::query()->firstOrCreate(['code' => $requestBatch['waveno']]);
+
+            if(!$batch)$batch=new Batch();
+            $batch->fill([
+                    'code' => $requestBatch['waveno'],
+                    'wms_type' => $requestBatch['batch_type']??'',
+                    'wms_status' => $requestBatch['docstatus']??'',
+                    'status' => '未处理',
+                    'wms_created_at' => $requestBatch['edittime']?Carbon::createFromFormat($editTimeFormat,$requestBatch['edittime']):'',
+            ]);
+            $batch->save();
+            $oracleAlloactions=OracleActAllocationDetails::query()->where('waveno',$requestBatch['waveno'])->get();
+            foreach($requestBatch['order_list'] as $requestOrder){
+                $owner=Owner::query()->where('code',$requestOrder['customerid'])->first();
+                $order=app("OrderService")->first(['code'=>$requestOrder['docno']]);
+                if(!$order){
+                    $order=app("OrderService")->createOrder([
+                        'batch_id' => $batch['id'],
+                        'code' => $requestOrder['docno'],
+                        'owner_id' => $owner['id'],
+                        'wms_status' => $requestOrder['docstatus']??'波次下发',
+                        'status' => '未处理',
+                    ]);
+                    app('LogService')->log(__METHOD__,__FUNCTION__,'创建 Order'.json_encode($order));
+                }else{
+                    $order['batch_id']= $batch['id'] ;
+                    $order['owner_id']=$order['owner_id']??$owner['owner_id'];
+                    $order['wms_status']=$order['wms_status']??$requestOrder['docstatus']??'波次下发';
+                    $order['status']=$order['status']??'未处理';
+                }
+                $order->save();
+                OrderBin::query()->firstOrCreate([
+                    'order_id' => $order['id'],
+                    'number' => $requestOrder['reservedfield01'],
+                ]);
+                foreach($requestOrder['barcode_list'] as $requestBarcode){
+                    $orderCommodity=OrderCommodity::query()
+                        ->where('order_id',$order['id'])->where('wms_ptltaskid',$requestBarcode['ptltaskid'])->first();
+                    if(!$orderCommodity){
+                        /** @var CommodityService $commodityService */
+                        $commodityService=app('CommodityService');
+                        $commodity=$commodityService->syncBarcodes($requestBarcode['alternate_sku1'],$owner['id'],$requestBarcode['sku']);
+                        $orderCommodity=OrderCommodity::query()->firstOrCreate(['order_id'=>$order['id'],'commodity_id'=>$commodity['id']]);
+                        if(!$orderCommodity){
+                            $orderCommodity = new OrderCommodity([
+                                'order_id' => $order['id'],
+                                'commodity_id' => $commodity['id'],
+                                'amount' => $requestBarcode['fmqty_each']??0,
+                                'wms_ptltaskid' => $requestBarcode['ptltaskid'],
+                            ]);
+                        }else{
+                            $orderCommodity['order_id']=$order['id'];
+                            $orderCommodity['commodity_id']=$commodity['id'];
+                            $orderCommodity['amount']=$requestBarcode['fmqty_each']??0;
+                            $orderCommodity['wms_ptltaskid']=$requestBarcode['ptltaskid']??0;
+                        }
+                        $allocation=$oracleAlloactions->where('orderno',$requestOrder['docno'])->where('sku',$commodity['sku'])->where('qty',$requestBarcode['fmqty_each'])->first();
+                        if($allocation)
+                            $orderCommodity['location'] = $allocation['location'];
+                        $orderCommodity->save();
+                    }
+                }
+            }
+        }
+        return response()->json(['Response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000',
+            'returnDesc'=>'消息处理成功:Success','resultInfo'=>'']]])->setEncodingOptions(JSON_UNESCAPED_UNICODE);
     }
     }
 
 
     protected function newBatchValidator(array $data)
     protected function newBatchValidator(array $data)