瀏覽代碼

内部使用oa后台

gogs 1 年之前
父節點
當前提交
a55bcaf07d
共有 1 個文件被更改,包括 34 次插入5 次删除
  1. 34 5
      app/Http/Controllers/Api/DeviceController.php

+ 34 - 5
app/Http/Controllers/Api/DeviceController.php

@@ -33,6 +33,8 @@ class DeviceController extends Controller
                     'number' => $v['account_id'],
                     'emp_fname' => $v['emp_fname'],
                     'crt_time' => substr($v['sign_time'],0,10),
+                    'flow_id' => $v['id'],
+                    'devid' => $v['devid'],
                 ];
                 $recodes[] = [
                     'id' => $v['id']
@@ -120,13 +122,40 @@ class DeviceController extends Controller
     }
 
 
-    public function capture(Request $request){
+    public function capture(Request $request)
+    {
+        //{"json":"{\"account_id\":\"23333\",\"card_sn\":\"12345\",\"devid\":\"001\",\"emp_fname\":\"诸杰伟\",\"emp_id\":\"23333\",\"id\":8,\"rec_type\":0,\"start_time\":\"1727248857342\",\"ver\":2}","picture":{"Illuminate\\Http\\UploadedFile":"/tmp/phpqJxfNO"}}
         $data = $request->all();
         Log::channel('apiLog')->info('smkq-capture', ['data' => $data]);
-    }
-
-
-
+        $data = json_decode($data['json'],true);
+        if ($request->hasFile('picture')) {
+            // 获取上传的文件对象
+            $file = $request->file('picture');
+
+            // 检查文件是否有效
+            if ($file->isValid()) {
+                // 设置保存路径和文件名(可以根据需要修改)
+                $date = date('Ymd');
+                $destinationPath = 'app/kq/' . $date; // 文件保存路径
+                $filename = time() . '_' . $file->getClientOriginalName(); // 生成文件名
+
+                // 移动文件到指定目录
+                $file->move(storage_path($destinationPath), $filename);
+
+                // 保存图片路径(可以存储到数据库等)
+                $imagePath = $destinationPath . '/' . $filename;
+                KqList::where('devid',$data['devid'])->where('flow_id',$data['id'])->update([
+                    'pic' => $imagePath
+                ]);
+                $return = [
+                    'devid' => $date['devid'],
+                    'emp_id' => $date['emp_id'],
+                    'id' => $date['id'],
+                ];
+                echo  json_encode($return);
+            }
+        }
 
 
+    }
 }