gogs há 8 meses atrás
pai
commit
6612003cc1

+ 66 - 3
app/Http/Controllers/Api/DwyController.php

@@ -950,7 +950,7 @@ class DwyController extends BaseController
         file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
 
         //单独的处理哪些口子不能用的逻辑
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
+        $url = 'http://122.112.196.99:7774/jbl/api/module-data/device/device/diy/device_code';
         $token = $param['token'];
         $json = ['device_code'=>$param['mac']];
         $header = [
@@ -975,7 +975,7 @@ class DwyController extends BaseController
 ////
 //            return $this->test();
 //        }
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
+        $url = 'http://122.112.196.99:7774/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
         $header = [
             'Content-Type:application/json',
             'Authorization: ' . $token,
@@ -1077,6 +1077,7 @@ class DwyController extends BaseController
                         'fake_qty' => $p_total,
 //                        'send_qty' => 0,
                         'restock_qty' => $vv['restock_qty'] ?? 0,
+                        'mat_material_a' => $vv['mat_material_a'] ?? []
                     ];
                     if($vv['restock_qty'] > 0) $list[$kk]['restock_qty'] = 0;
                     $v['product_list'][] = $key_arr;
@@ -1098,7 +1099,7 @@ class DwyController extends BaseController
         });
 //        list($status,$msg) = DwyService::getInstance()->setLimitForBoxOut($param);
 //        if(! $status) return ['status' => '201', 'data' => [],'msg'=> $msg];
-        $this->unusualRestock($data,$mac,$token);
+        $this->unusualRestock1($data,$mac,$token);
         if(empty($data))  return ['status' => '201', 'data' => $data,'msg'=>'无商标需要申领'];
         return ['status' => '200', 'data' => $data];
     }
@@ -1166,6 +1167,68 @@ class DwyController extends BaseController
             file_put_contents('dwy1.txt', date('Y-m-d H:i:s').$res . PHP_EOL, 8);
         }
     }
+    public function unusualRestock1($data,$mac,$token){
+        $send_status = true;
+        $send_data = [];
+        //2024-06-19T21:01:51.948Z,赖的写,直接拼
+        $iso8601Time = date('Y-m-d').'T'.date('H:i:s').'.'.rand(100,999).'Z';
+        foreach ($data as $v){
+            if($v['send_qty'] > 0) $send_status = false;
+            $send_product = [];
+            //创建异常数据
+            $box_data = [
+                'in_out_type_code' => 'CK00004',
+                'in_out_type_code_show' => '商标仓正常领标出库',
+                'send_box_code' => $v['box_code'],
+                'send_box_code_show' => $v['box_code_show'],
+                'device_code' => $mac,
+                'get_brand_source_dk' => 'SALE_ORDER',
+                'abnormal_flag' => false,
+                'abnormal_date' => $iso8601Time,
+            ];
+            foreach ($v['product_list'] as $kk=>$vv){
+                $send_product[] = [
+                    'item_no' => 10+$kk*10,
+                    'brand_qr_code_list' => '',
+                    'material_code' => $v['material_code'],
+                    'material_code_show' => $v['material_code_show'],
+                    'unit_code' => $v['unit_code'],
+                    'unit_code_show' => $v['unit_code_show'],
+                    'restock_qty' => $vv['restock_qty'],
+                    'qty' => 0,
+                    'fake_qty' => 0,
+                    'bus_type_dk' => 'SALE_ORDER',
+                    'bus_type_dk_show' => '销售订单',
+                    'bus_no' => $vv['order_item_id'],
+                    'bus_no_show' => $vv['order_item_id_show'],
+                    'product_code' => $vv['product_code'],
+                    'product_code_show' => $vv['product_code_show'],
+                    'process_title' => $vv['process_title'],
+                    'color' => $vv['color'],
+                    'process_title_two' => $vv['process_title_two'],
+                    'color_two' => $vv['color_two'],
+                ];
+            }
+            $box_data['brand_out_stock_dtl'] =$send_product;
+
+            $send_data[] = $box_data;
+        }
+        $param = [
+            'brand_out_stock_list' => $send_data
+        ];
+        if($send_status){
+            $url = 'http://122.112.196.99:7774/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
+            $header = [
+                'Content-Type:application/json',
+                'Authorization: ' . $token,
+            ];
+            $res = $this->post_helper($url, json_encode($param), $header);
+
+            file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($header) . PHP_EOL, 8);
+            file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($param) . PHP_EOL, 8);
+            file_put_contents('dwy1.txt', date('Y-m-d H:i:s').$res . PHP_EOL, 8);
+        }
+    }
 
     public function zjlb(Request $request)
     {

+ 2 - 2
app/Jobs/LabelDealCsJob.php

@@ -45,13 +45,13 @@ class LabelDealCsJob implements ShouldQueue
             Log::channel('apiLog')->info('测试--出库(清洗数据)', ["param" => $return]);
 
             //调用外部方法
-            list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData($this->header,$dv,$return,$box_list,$data);
+            list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData1($this->header,$dv,$return,$box_list,$data);
 
             //删除限制
             DwyService::getInstance()->delLimitForBoxOut($lead_bind);
 
             //调用保存接口 cs todo
-            LabelDealService::getInstance()->boxOut($lead_bind,$lead_out,$this->header,$this->id);
+            LabelDealService::getInstance()->boxOut1($lead_bind,$lead_out,$this->header,$this->id);
         }catch (\Throwable $exception){
             Log::channel('apiLog')->info('测试--队列捕获(出库异常)', ["message" => $exception->getFile() . "|" . $exception->getLine() . "|" . $exception->getMessage(). "|"  . $exception->getCode()]);
             $this->delete();

+ 150 - 0
app/Service/DwyService.php

@@ -10,6 +10,7 @@ namespace App\Service;
 class DwyService extends Service
 {
     private $url = 'https://tm.dwycloud.com';
+    private $url1 = 'https://tm.dwycloud.com';
 
     protected $num = 0;
 
@@ -84,6 +85,67 @@ class DwyService extends Service
         return [$lind_bind,$lead_out];
 
     }
+    public function setBoxData1($token,$dv,$data,$box_list,$old_data){
+        //
+        $this->num = 0;
+
+//        测试
+//        $token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1ODg5MzM1OTMwMTE3MjAxOTIiLCJhdXRoIjoiUk9MRV9JTlRFUkZBQ0UsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9PVVRFUl9VU0VSLFJPTEVfSU5ORVJfVVNFUiIsInRva2VuSWQiOiIyIiwiZXhwIjoxNzIxMDExNjcwfQ.T8M-h2_EbBLU9xxMUP52c4B_OtzIRLWdLOYru8qE0Zi0k9PfIfYff8TxaQ9Kux8j6_2zJW1asSODjK3slNsNYQ';
+//        $dv = 'cff4dc68c73115b';/**/
+//        $box_list = [
+//            'CK00009',
+//            'CK00018',
+//        ];
+//
+//        $old_data = json_decode(file_get_contents('38929.txt'),true);
+//        var_dump($old_data);die;
+//        处理数据
+//        list ($data,$box_list) = $this->clearData($old_data);
+//        var_dump($data);die;
+//        var_dump($box_list);die;
+//        dd($old_data);die;
+        //请求获取仓位卷码信息
+        $box_roll_list = $this->getBoxData1($dv,$token,$box_list);
+//        var_dump($box_roll_list);die;
+        $new_data = [];
+        foreach ($data as $k=>$box_detail){
+            foreach ($box_detail['detail'] as $v){
+
+                foreach ($box_roll_list as $roll_number=>$roll_detail){
+
+                    if(in_array($v,$roll_detail['detail'])){
+                        if(!isset($new_data[$roll_detail['box_code']])) $new_data[$roll_detail['box_code']] = [
+                            'detail' => [],
+                            'fake_qty' => $data[$roll_detail['box_code']]['fake_qty'],
+                            'material_code' =>  $roll_detail['material_code'],
+                            'roll_number' => $roll_number
+                        ];
+                        $new_data[$roll_detail['box_code']]['detail'][] = $v;
+                        break;
+                    }
+                }
+
+            }
+        }
+        //补全数据
+        if($dv === 'a6a672c3e458bed2'&&false){
+            $new_data = $this->setBoxFake($new_data);
+            list($lind_bind,$lead_out) = $this->setNewData1($old_data,$new_data);
+        }else{
+            list($lind_bind,$lead_out) = $this->setNewData2($old_data,$new_data);
+        }
+//
+        //把数据拼回去
+//        var_dump($data);die;
+//        var_dump($old_data);die;
+
+
+//        var_dump($lind_bind);
+//        var_dump($lead_out);die;
+//        die('ddd');
+        return [$lind_bind,$lead_out];
+
+    }
 
     public function clearData($data){
         $return = [];
@@ -163,6 +225,56 @@ class DwyService extends Service
 //        var_dump($lead_out);die;
         return [$lind_bind,['brand_out_stock_list'=>$lead_out]];
     }
+    private function setNewData2($old_data,$data){
+//        var_dump($old_data);
+        $code_key_data = [];
+        foreach ($data as $v){
+            if(!isset($code_key_data[$v['material_code']])) $code_key_data[$v['material_code']] = [];
+            $code_key_data[$v['material_code']] = array_merge($code_key_data[$v['material_code']],$v['detail']);
+        }
+        $lind_bind = $old_data['lead_bind'];
+        $lind_bind_key_list = [];
+        foreach ($lind_bind['material_list'] as &$l){
+//            unset($l['brand_qr_code_list']);
+//            $l['qty'] = $l['fake_qty'];
+//            $l['brand_qr_code_list'] = $this->getValues( $code_key_data[$l['material_code']],$l['qty']);
+            $lind_bind_key_list[$l['order_item_id']] = [
+                'product_code' => $l['product_code'],
+                'product_code_show' => $l['product_code_show'],
+                'process_title' => $l['process_title']??'',
+                'color' => $l['color']??'',
+                'process_title_two' => $l['process_title_two']??'',
+                'color_two' => $l['color_two']??'',
+                'mat_material_a' => $l['mat_material_a']
+            ];
+            unset($l['fake_qty']);
+        }
+
+        $lead_out = $old_data['lead_out']['brand_out_stock_list'];
+        foreach ($lead_out as &$ll){
+            foreach ($ll['brand_out_stock_dtl'] as &$lll){
+//                unset($lll['brand_qr_code_list']);
+//                $lll['qty'] = $ll['brand_out_stock_dtl'][0]['fake_qty'];
+//                $lll['qty'] = $lll['fake_qty'];
+//                unset($lll['fake_qty']);
+
+//            var_dump($data[$ll['send_box_code']]);
+//                $lll['brand_qr_code_list'] = implode(',',$data[$ll['send_box_code']]['detail']);
+//                $lll['brand_qr_code_list'] =  implode(',',$this->getValues( $data[$ll['send_box_code']]['detail'],$lll['qty']));;
+                $lll['product_code'] = $lind_bind_key_list[$lll['bus_no']]['product_code'] ?? '';
+                $lll['product_code_show'] = $lind_bind_key_list[$lll['bus_no']]['product_code_show'] ?? '';
+                $lll['process_title'] = $lind_bind_key_list[$lll['bus_no']]['process_title'] ?? '';
+                $lll['color'] = $lind_bind_key_list[$lll['bus_no']]['color'] ?? '';
+                $lll['process_title_two'] = $lind_bind_key_list[$lll['bus_no']]['process_title_two'] ?? '';
+                $lll['color_two'] = $lind_bind_key_list[$lll['bus_no']]['color_two'] ?? '';
+            }
+
+        }
+        file_put_contents('1.txt',json_encode(['lind_bind'=>$lind_bind,'lead_out'=>['brand_out_stock_list'=>$lead_out]]));
+//        var_dump($lind_bind);
+//        var_dump($lead_out);die;
+        return [$lind_bind,['brand_out_stock_list'=>$lead_out]];
+    }
     private function setNewData1($old_data,$data){
 //        var_dump($old_data);
         $code_key_data = [];
@@ -274,6 +386,44 @@ class DwyService extends Service
 
 
     }
+    private function getBoxData1($dv,$token,$box_list){
+
+        //为了取商标卷码
+        $res = $this->post_helper($this->url1.'/jbl/api/module-data/device/device/diy/device_code',['device_code'=>$dv],$token);
+        $res = json_decode($res,true);
+        $detail = [];
+        $qr_codes = [];
+        if(isset($res['data'])){
+            foreach ($res['data'] as $v){
+                if(in_array($v['box_code'],$box_list)){
+                    $detail[$v['roll_qr_code']] = $v['box_code'];
+                    $qr_codes[] = $v['roll_qr_code'];
+                }
+
+            }
+        }else{
+            return [false,''];
+        }
+        //为了取仓对应卷码进行获取
+        $res = $this->post_helper($this->url1.'/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list',['roll_qr_code_list'=>$qr_codes],$token);
+        $res = json_decode($res,true);
+        $qr_roll_list = [];
+        if(isset($res['data'])){
+            foreach ($res['data'] as $v){
+//                if(!empty($v['out_brand_qr_code'])) continue;
+                if(!isset($qr_roll_list[$v['roll_qr_code']]['material_code']))  {
+                    $qr_roll_list[$v['roll_qr_code']]['material_code'] = $v['material_code'];
+                    $qr_roll_list[$v['roll_qr_code']]['box_code'] = $detail[$v['roll_qr_code']];
+                }
+                $qr_roll_list[$v['roll_qr_code']]['detail'][] = $v['brand_qr_code'];
+            }
+        }
+
+
+        return $qr_roll_list;
+
+
+    }
 
     //限制领标
     public function setLimitForBoxOut($data){

+ 2 - 1
routes/api.php

@@ -22,6 +22,7 @@ Route::any('openCommand', 'Api\DwyController@openCommand');
 Route::any('getOpenCommand', 'Api\DwyController@getOpenCommand');
 Route::any('openDoor', 'Api\DwyController@openDoor');
 Route::any('setLb', 'Api\DwyController@setLb');
+Route::any('setLb1', 'Api\DwyController@setLb1');
 Route::any('boxList', 'Api\DwyController@boxList');
 Route::any('andriodLog', 'Api\DwyController@andriodLog');
 Route::any('ttttt', 'Api\TestController@deviceCallback');
@@ -64,7 +65,7 @@ Route::any('tttt', 'Api\DwyController@tttt');
 Route::any('getBoxTrademark', 'Api\DwyController@getBoxTrademark');
 Route::any('aaaa', 'Api\DwyController@setBoxTrademark');
 Route::any('boxOut', 'Api\JobController@labelDeal');
-Route::any('boxOutCs', 'Api\JobController@labelDealCs');
+Route::any('boxOut1', 'Api\JobController@labelDealCs');
 Route::any('getObsUrl', 'Api\DwyController@getObsUrl');
 Route::any('getCbLog', 'Api\LoginController@getCbLog');