Zhouzhendong 6 anos atrás
pai
commit
4b6834fc47

+ 8 - 3
app/Http/Controllers/api/thirdPart/weight/PackageController.php

@@ -31,9 +31,14 @@ class PackageController extends Controller
 
         $measuringMachine=MeasuringMachine::where('code',$request->id)->first();
         if (!$measuringMachine){
-            $this->log(__METHOD__,'weightApi(no measuring machine)'.__FUNCTION__,json_encode($request->all()),null);
-            $response=["msg"=>"设备未录入在系统中","code"=>500,"data"=>null];
-            return json_encode($response,JSON_UNESCAPED_UNICODE);
+            $measuringMachine=new MeasuringMachine([
+                'name'=>$request->id,
+                'code'=>$request->id
+            ]);
+            $measuringMachine->save();
+            $this->log(__METHOD__,'weightApi(new measuring machine)'.__FUNCTION__,json_encode($request->all()),null);
+            /*$response=["msg"=>"设备未录入在系统中","code"=>500,"data"=>null];
+            return json_encode($response,JSON_UNESCAPED_UNICODE);*/
         }
 
         $package=Package::where('logistic_number',$request->barcode)->first();

+ 23 - 0
tests/webApi/test.http

@@ -0,0 +1,23 @@
+# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection).
+##
+## Following HTTP Request Live Templates are available:
+## * 'gtrp' and 'gtr' create a GET request with or without query parameters;
+## * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body;
+## * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data);
+
+POST http://bswas/api/thirdPart/weight/new
+Content-Type: application/json
+
+{"key": "2C7FACD3AFC3FFE547FC54CDA076A25D",
+  "id": "1456",
+  "barcode": "testWeight23",
+  "weight": "13",
+  "length": "23",
+  "width": "42",
+  "height": "13"
+}
+
+###
+
+
+