cqpCow 1 year ago
parent
commit
5a5240b4a6
2 changed files with 395 additions and 1 deletions
  1. 392 1
      app/Http/Controllers/Api/TestController.php
  2. 3 0
      routes/api.php

+ 392 - 1
app/Http/Controllers/Api/TestController.php

@@ -4,19 +4,342 @@ namespace App\Http\Controllers\Api;
 
 
 use App\Model\BoxDetail;
+use App\Model\DispatchSub;
+use App\Model\OrdersProduct;
+use App\Model\SaleOrdersProduct;
 use App\Service\FinishedOrderService;
 use App\Service\MeasureService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Storage;
 
 
 class TestController extends BaseController
 {
 
     public function tt(){
-        die('123132');
+//        die('d');
+
+        $list = SaleOrdersProduct::where('out_order_no_time','<','1693497600')->where('production_quantity',0)->orderBy('id','desc')->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/productionAdd';
+        echo count($list);
+        die;
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            $post = [
+                'id' => [$v['id']],
+                'quantity' => [$v['order_quantity']],
+            ];
+            $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+            echo $a;
+        }
+    }
+    public function tt1(){
+
+        $list = SaleOrdersProduct::where('out_order_no_time','<','1693497600')->where('production_quantity',0)->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/productionAdd';
+        echo count($list);
+
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            $post = [
+                'id' => [$v['id']],
+                'quantity' => [$v['order_quantity']],
+            ];
+            $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+            echo $a;
+        }
+    }
+
+    public function ttt(){
+        $list = OrdersProduct::where('production_time','>','1697385600')->where('dispatch_complete_quantity',0)->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/dispatchAdd';
+        $n = 0;
+        $ids = [];
+        $out_order_no_times = [];
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            if($n < 20){
+                $ids[] = $v['id'];
+                $out_order_no_times[] = $v['order_quantity'];
+                $n++;
+            }
+            if($n == 20){
+                $post = [
+                    'dispatch_time' => [$v['out_order_no_time']+86400,$v['out_order_no_time']+(86400*2)],
+                    'employee_id' => [rand(431,432)],
+                    'equipment_id' => 11,
+                    'id' => $ids,
+                    'is_split' => 1,
+                    'out_order_no_time' => [$v['out_order_no_time']+86400,$v['out_order_no_time']+(86400*2)],
+                    'process_id' => 9,
+                    'quantity' => $out_order_no_times,
+                    'team_id' => 68,
+                ];
+                $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+                var_dump($a);
+                $n = 0;
+                $ids = [];
+                $out_order_no_times = [];
+            }
+
+
+        }
+    }
+    public function ttt1(){
+        $list = OrdersProduct::where('production_time','>','1697385600')->where('dispatch_complete_quantity',0)->orderBy('id','desc')->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/dispatchAdd';
+        var_dump(count($list));
+        $n = 0;
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            if($n < 20){
+                $ids[] = $v['id'];
+                $out_order_no_times[] = $v['order_quantity'];
+                $n++;
+            }
+            if($n == 20){
+                $post = [
+                    'dispatch_time' => [$v['out_order_no_time']+86400,$v['out_order_no_time']+(86400*2)],
+                    'employee_id' => [rand(431,432)],
+                    'equipment_id' => 11,
+                    'id' => $ids,
+                    'is_split' => 1,
+                    'out_order_no_time' => [$v['out_order_no_time']+86400,$v['out_order_no_time']+(86400*2)],
+                    'process_id' => 9,
+                    'quantity' => $out_order_no_times,
+                    'team_id' => 68,
+                ];
+                $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+                var_dump($a);
+                $n = 0;
+                $ids = [];
+                $out_order_no_times = [];
+            }
+
+
+        }
+    }
+
+    public function tttt(){
+        ini_set('output_buffering', 'off');
+        // 立即发送所有输出
+        ini_set('implicit_flush', 'on');
+        // 设置执行时间不限制
+        set_time_limit(0);
+        $list = DispatchSub::where('crt_time','>','1697385600')->where('finished_num',0)->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/finishedOrderAdd';
+        echo count($list);
+        $n = 0;
+        $ids = [];
+        $out_order_no_times = [];
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            if($n < 2){
+                $ids[] = $v['id'];
+                $out_order_no_times[] = $v['dispatch_quantity'];
+                $n++;
+            }
+            if($n == 2){
+                $post = [
+                    'equipment_id' => 11,
+                    'finish_id' => [rand(431,432)],
+                    'id' => $ids,
+                    'quantity' => $out_order_no_times,
+                    'team_id' => 68,
+                    'waste' => [[]],
+                ];
+                sleep(10);
+                $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+                echo $a;
+                $n = 0;
+                $ids = [];
+                $out_order_no_times = [];
+            }
+
+//            flush();die;
+
+        }
     }
+    public function tttt1(){
+        ini_set('output_buffering', 'off');
+        // 立即发送所有输出
+        ini_set('implicit_flush', 'on');
+        // 设置执行时间不限制
+        set_time_limit(0);
+        $list = DispatchSub::where('crt_time','>','1697385600')->where('finished_num',0)->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/finishedOrderAdd';
+        echo count($list);
+        $n = 0;
+        $ids = [];
+        $out_order_no_times = [];
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            if($n < 2){
+                $ids[] = $v['id'];
+                $out_order_no_times[] = $v['dispatch_quantity'];
+                $n++;
+            }
+            if($n == 2){
+                $post = [
+                    'equipment_id' => 11,
+                    'finish_id' => [rand(431,432)],
+                    'id' => $ids,
+                    'quantity' => $out_order_no_times,
+                    'team_id' => 68,
+                    'waste' => [[]],
+                ];
+                sleep(10);
+                $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+                echo $a;
+                $n = 0;
+                $ids = [];
+                $out_order_no_times = [];
+            }
 
+//            flush();die;
+
+        }
+    }
+
+    public function aa1(){
+        ini_set('output_buffering', 'off');
+        // 立即发送所有输出
+        ini_set('implicit_flush', 'on');
+        // 设置执行时间不限制
+        set_time_limit(0);
+        $list = DispatchSub::where('crt_time','>','1697385600')->where('finished_num',0)->get()->toArray();
+        $url = 'https://fyy_api.qingyaokeji.com/api/finishedOrderAdd';
+        echo count($list);
+        $n = 0;
+        $ids = [];
+        $out_order_no_times = [];
+        foreach ($list as $v){
+            $header = [
+                'Authorization' => '[personalComputer]eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2OTc0NDMzMzMsIm5iZiI6MTY5NzQ0MzMzMiwiZXhwIjoxNzA2MDgzMzMzLCJkYXRhIjp7InVzZXJfaWQiOjF9fQ.wP5c0fPquR6mWYWdAIudf-J60aUBQiSYAmCaI0bWx6k',
+                'Zt'=> '999'
+            ];
+            if($n < 1){
+                $ids[] = $v['id'];
+                $out_order_no_times[] = $v['dispatch_quantity'];
+                $n++;
+            }
+            if($n == 1){
+                $post = [
+                    'equipment_id' => 11,
+                    'finish_id' => [rand(431,432)],
+                    'id' => $ids,
+                    'quantity' => $out_order_no_times,
+                    'team_id' => 68,
+                    'waste' => [[]],
+                ];
+                var_dump($post);
+                $a = $this->curlOpen($url,['header'=>$header,'post'=>$post]);
+                var_dump($a);die;
+                $n = 0;
+                $ids = [];
+                $out_order_no_times = [];
+            }
+
+//            flush();die;
+
+        }
+    }
+    function curlOpen($url, $config = array())
+    {
+        $arr = array('post' => false,'referer' => $url,'cookie' => '', 'useragent' => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; customie8)', 'timeout' => 100, 'return' => true, 'proxy' => '', 'userpwd' => '', 'nobody' => false,'header'=>array(),'gzip'=>true,'ssl'=>true,'isupfile'=>false,'returnheader'=>false,'request'=>'post');
+        $arr = array_merge($arr, $config);
+        $ch = curl_init();
+
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, $arr['return']);
+        curl_setopt($ch, CURLOPT_NOBODY, $arr['nobody']);
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+        curl_setopt($ch, CURLOPT_USERAGENT, $arr['useragent']);
+        curl_setopt($ch, CURLOPT_REFERER, $arr['referer']);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $arr['timeout']);
+
+
+        curl_setopt($ch, CURLOPT_HEADER, $arr['returnheader']);//��ȡheader
+        if($arr['gzip']) curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
+        if($arr['ssl'])
+        {
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        }
+        if(!empty($arr['cookie']))
+        {
+            curl_setopt($ch, CURLOPT_COOKIEJAR, $arr['cookie']);
+            curl_setopt($ch, CURLOPT_COOKIEFILE, $arr['cookie']);
+        }
+
+        if(!empty($arr['proxy']))
+        {
+            //curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+            curl_setopt ($ch, CURLOPT_PROXY, $arr['proxy']);
+            if(!empty($arr['userpwd']))
+            {
+                curl_setopt($ch,CURLOPT_PROXYUSERPWD,$arr['userpwd']);
+            }
+        }
+
+        //ip�Ƚ����⣬�ü�ֵ��ʾ
+        if(!empty($arr['header']['ip']))
+        {
+            array_push($arr['header'],'X-FORWARDED-FOR:'.$arr['header']['ip'],'CLIENT-IP:'.$arr['header']['ip']);
+            unset($arr['header']['ip']);
+        }
+        $arr['header'] = array_filter($arr['header']);
+        if(!empty($arr['header']))
+        {
+            $header = [];
+            foreach ($arr['header'] as $k=>$v){
+                $header[] = $k.':'.$v;
+            }
+            $header[] = 'Content-Type: application/json';
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+        }
+
+        if($arr['request'] === 'put'){
+            curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+            curl_setopt($ch, CURLOPT_POSTFIELDS,$arr['post']);
+        }elseif($arr['post'] != false)
+        {
+            curl_setopt($ch, CURLOPT_POST, true);
+//            if(is_array($arr['post']) && $arr['isupfile'] === false)
+//            {
+//                $post = http_build_query($arr['post']);
+//            }
+//            else
+//            {
+//                $post = $arr['post'];
+//            }
+            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arr['post']));
+        }
+
+        $result = curl_exec($ch);
+        curl_close($ch);
+
+        return $result;
+    }
     public function aa(){
         $data = [
             'out_order_no' => 'test123',
@@ -68,6 +391,7 @@ class TestController extends BaseController
 
 
 public function testData(Request $request){
+        date_default_timezone_set('PRC');
         $arr = ['title' => json_encode($request->all()),
             'crt_time' => date('Y-m-d H:i:s')
         ];
@@ -937,6 +1261,51 @@ public function nu_work_order(Request $request){
 //        ];
 //        return $this->json_return(200,'',$arr);
 //    }
+public function testFile(Request $request){
+    $data = $request->all();
+    $file = $request->file('file');
+    $filename = $this->uploadItemBillFile($file);
+    // 使用 'public' 磁盘驱动来获取文件路径
+    $filePath = Storage::disk('public')->path('big_tree\\'.$filename);
+
+    $url = $data['url'];
+    $header = $data['header'];
+    $header = explode(',',$header);
+
+    $curl = curl_init();
+
+    curl_setopt_array($curl, array(
+        CURLOPT_URL => $url,
+        CURLOPT_RETURNTRANSFER => true,
+        CURLOPT_ENCODING => '',
+        CURLOPT_MAXREDIRS => 10,
+        CURLOPT_TIMEOUT => 0,
+        CURLOPT_FOLLOWLOCATION => true,
+        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+        CURLOPT_CUSTOMREQUEST => 'POST',
+        CURLOPT_POSTFIELDS => ['file' => new \CURLFile($filePath)],
+//        CURLOPT_HTTPHEADER => $header,
+    ));
+    $response = curl_exec($curl);
+    curl_close($curl);
+    Storage::disk('public')->delete('big_tree\\'.$filename);
+
+    return $this->json_return(200,'',json_decode($response,true));
+}
+
+    public function uploadItemBillFile($file){
+        // 获取文件相关信息
+        $ext = $file->getClientOriginalExtension();     // 扩展名
+        $realPath = $file->getRealPath();   //临时文件的绝对路径
+
+        // 上传文件
+        $file_name = time().rand(1000,9999);
+        $filename =  $file_name.'.' . $ext;
+        // 使用我们新建的uploads本地存储空间(目录)
+        Storage::disk('public')->put('big_tree/'.$filename, file_get_contents($realPath));
+
+        return $file_name. '.' .$ext;
+    }
 
 public function testaa(Request $request){
     $data = $request->all();
@@ -1045,4 +1414,26 @@ dump(json_decode($response,true));die;
         list($status,$msg) =  (new FinishedOrderService())->addInJob($data['result'],$data['data']);
         dump($msg);die;
     }
+
+    public function te(){dump(222);die;
+        $query = DB::table('orders_product_bom_process_202301_03 as bom')
+            ->join('orders_product as op', function ($join) {
+                $join->on('op.order_no', '=', 'bom.order_no')
+                    ->on('op.product_no', '=', 'bom.product_no')
+                    ->on('op.out_order_no', '=', 'bom.out_order_no');
+            })
+            ->where('bom.order_product_id', 4461)
+            ->orderBy('bom.id','asc')
+            ->select('bom.id','op.id as oid')
+            ->chunk(10, function ($results) {dump($results);die;
+                foreach ($results as $result) {
+                    // 处理每个分块的数据
+                    $id = $result->id;
+                    $orderProductId = $result->order_product_id;
+                    $oid = $result->oid;
+
+                    // 在这里进行你的逻辑处理
+                }
+            });
+    }
 }

+ 3 - 0
routes/api.php

@@ -24,6 +24,8 @@ Route::any('getHeaderSetting', 'Api\HeaderWordController@getHeaderSettings');
 Route::any('deviceList', 'Api\Device\DeviceController@deviceList');
 Route::any('fyy_set','Api\FyyOrderController@setFyy');
 Route::any('tt','Api\TestController@tt');
+Route::any('ttt','Api\TestController@ttt');
+Route::any('tttt','Api\TestController@tttt');
 Route::any('getProductionOrder/{file_name}','Api\ProductionOrderController@getItemFile');
 Route::any('getCloudData','Api\CloudDataController@getCloudData');
 
@@ -34,6 +36,7 @@ Route::any('testdwy','Api\TestController@testaa');
 Route::any('testdwyget','Api\TestController@testa');
 Route::any('testaa1','Api\TestController@testaa1');
 Route::any('testapp','Api\TestController@testapp');
+Route::any('upload','Api\TestController@testFile');
 //Route::any('order_process1','Api\TestController@order_process1');
 //Route::any('project_region','Api\TestController@project_region');
 //Route::any('output_value_month1','Api\TestController@output_value_month1');