cqp vor 1 Monat
Ursprung
Commit
f39b32089c

+ 10 - 0
app/Http/Controllers/Api/TestController.php

@@ -130,4 +130,14 @@ class TestController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function recordList(Request $request){
+        list($bool, $data) = (new TestService())->recordList($request->all());
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 1 - 0
app/Http/Kernel.php

@@ -67,6 +67,7 @@ class Kernel extends HttpKernel
         'CheckJRFIDLogin' => \App\Http\Middleware\CheckJRFIDLogin::class,
         'CheckAssetLogin' => \App\Http\Middleware\CheckAssetLogin::class,
         'checkWeixin' => \App\Http\Middleware\CheckWeinxin::class,
+        'U8Deal' => \App\Http\Middleware\U8Deal::class,
     ];
 
     /**

+ 53 - 0
app/Http/Middleware/U8Deal.php

@@ -0,0 +1,53 @@
+<?php
+namespace App\Http\Middleware;
+
+use App\Model\RecordTable;
+use Closure;
+use Illuminate\Http\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+class U8Deal
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle(Request $request, Closure $next)
+    {
+        // 在这里可以添加请求前的操作,但通常我们只关心请求后的操作。
+        return $next($request);
+    }
+
+    /**
+     * Handle the request termination.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Illuminate\Http\Response  $response
+     * @return void
+     */
+    public function terminate(Request $request, Response $response)
+    {
+        $return = json_decode($response->content(),true);
+
+        if(isset($return['code'])){
+            $path = $request->path();
+            $type = 0;
+            if($path == "api/materialAddU8"){
+                $type = RecordTable::type_one;
+            }elseif ($path == "api/productInAddU8"){
+                $type = RecordTable::type_two;
+            }elseif ($path == ""){
+                $type = RecordTable::type_three;
+            }
+            RecordTable::insert([
+               'msg' => $return['msg'] ?? "",
+               'data' => json_encode($request->all()),
+               'crt_time' => time(),
+               'type' => $type,
+            ]);
+        }
+    }
+}

+ 24 - 0
app/Model/RecordTable.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class RecordTable extends Model
+{
+    protected $table = "record_table"; //指定表
+    const CREATED_AT = null;
+    const UPDATED_AT = null;
+    protected $dateFormat = 'U';
+    protected $guarded = [];
+
+    const type_one = 1;
+    const type_two = 2;
+    const type_three = 3;
+
+    public static $type = [
+        self::type_one => "领料申请单",
+        self::type_two => "产成品入库单",
+        self::type_three => "发货单",
+    ];
+}

+ 29 - 4
app/Service/TestService.php

@@ -2,6 +2,7 @@
 
 namespace App\Service;
 
+use App\Model\RecordTable;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Config;
 use Illuminate\Support\Facades\DB;
@@ -415,6 +416,7 @@ class TestService extends Service
         return [true, ''];
     }
 
+    //-----------------------------------朗峰u8-----
     public function getToken(){
         list($status, $msg) = $this->SetU8();
         if(! $status) return [false , $msg];
@@ -446,8 +448,6 @@ class TestService extends Service
         return [true, [$host, $token]];
     }
 
-    //-----------------------------------朗峰u8-----
-
     public function salesOrderGet($data){
         list($status, $msg) = $this->getToken();
         if(! $status) return [false, $msg];
@@ -556,7 +556,7 @@ class TestService extends Service
         if(empty($data['iHead'])) return [false, '领料单表头信息不能为空'];
         if(empty($data['iBody'])) return [false, '领料单表体信息不能为空'];
 
-        $header = ["Authorization: {$token}",'Content-Type:application/json'];;
+        $header = ["Authorization: {$token}",'Content-Type:application/json'];
         $url = $host . "/api/MaterialRequest/Add";
         $json[] = [
             "Inum" => "MaterialRequest",
@@ -565,8 +565,9 @@ class TestService extends Service
                 "iBody" => $data['iBody'],
             ],
         ];
+        $json_str = json_encode($json);
 
-        list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30);
+        list($status, $result) = $this->post_helper($url, $json_str, $header, 30);
         if(! $status) return [false, $result];
         if(! isset($result['code'])) return [false, '异常错误,请联系开发者'];
         if($result['code'] != 0) return [false, $result['msg']];
@@ -630,6 +631,30 @@ class TestService extends Service
         return [true, $result['data']];
     }
 
+    public function recordList($data){
+        $model = RecordTable::where('del_time',0)
+            ->select('msg','data','type','crt_time')
+            ->orderBy('id','desc');
+
+        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) $model->whereBetween('crt_time',[$data['crt_time'][0],$data['crt_time'][1]]);
+        if(! empty($data['type'])) $model->where('type',$data['type']);
+
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list);
+
+        return [true,$list];
+    }
+
+    private function fillData($data){
+        if(empty($data['data'])) return $data;
+
+        foreach ($data['data'] as $key => $value){
+            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
+            $data['data'][$key]['type_name'] = RecordTable::$type[$value['type']] ?? '';
+        }
+
+        return $data;
+    }
     /**
      * 补全用友发货单子表金额字段(含换算率)
      * 输入示例:

+ 9 - 8
routes/api.php

@@ -52,18 +52,19 @@ Route::any('saleOrdersFromAddress','Api\ReportFormsController@saleOrdersFromAddr
 Route::any('production_status','Api\ReportFormsController@production_status');
 
 //更新t9总社库存
-Route::any('updateTopStock', 'Api\TestController@updateTopStock');
+//Route::any('updateTopStock', 'Api\TestController@updateTopStock');
 //更新t9获取sn
-Route::any('getSnList', 'Api\TestController@getSnList');
-Route::any('getSnforMap', 'Api\TestController@getSnforMap');
-Route::any('getSnForWarranty', 'Api\TestController@getSnForWarranty');
-Route::any('saveSnUseData', 'Api\TestController@saveSnUseData');
+//Route::any('getSnList', 'Api\TestController@getSnList');
+//Route::any('getSnforMap', 'Api\TestController@getSnforMap');
+//Route::any('getSnForWarranty', 'Api\TestController@getSnForWarranty');
+//Route::any('saveSnUseData', 'Api\TestController@saveSnUseData');
 
 //朗峰
+Route::any('recordList', 'Api\TestController@recordList');
 Route::any('salesOrderGet', 'Api\TestController@salesOrderGet');
-Route::any('materialAddU8', 'Api\TestController@materialAddU8');
-Route::any('productInAddU8', 'Api\TestController@productInAddU8');
-Route::any('dispatchAddU8', 'Api\TestController@dispatchAddU8');
+Route::any('materialAddU8', 'Api\TestController@materialAddU8')->middleware('U8Deal');;
+Route::any('productInAddU8', 'Api\TestController@productInAddU8')->middleware('U8Deal');;
+Route::any('dispatchAddU8', 'Api\TestController@dispatchAddU8')->middleware('U8Deal');;
 
 Route::group(['middleware'=> ['CheckJRFIDLogin']],function ($route){
     //站点获取登录后