cqpCow 1 år sedan
förälder
incheckning
5de2ddb4e4

+ 22 - 0
app/Http/Controllers/Api/SystemRecordController.php

@@ -17,4 +17,26 @@ class SystemRecordController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function warningList(Request $request){
+        $service = new SystemRecordService();
+        list($status,$data) = $service->warningList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function warningEdit(Request $request){
+        $service = new SystemRecordService();
+        list($status,$data) = $service->warningEdit($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 13 - 0
app/Model/Warning.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Warning extends Model
+{
+    protected $table = "warning"; //指定表
+    const CREATED_AT = null;
+    const UPDATED_AT = null;
+    protected $dateFormat = 'U';
+}

+ 20 - 0
app/Service/SystemRecordService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\SystemRecord;
+use App\Model\Warning;
 
 class SystemRecordService extends Service
 {
@@ -30,4 +31,23 @@ class SystemRecordService extends Service
 
         return $data;
     }
+
+    public function warningList($data){
+        $list = Warning::where('state',0)
+            ->where('value',1)
+            ->select('code','data_point_name','time')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+        foreach ($list as $key => $value){
+            $list[$key]['time'] = date("Y-m-d H:i:s",$value['time']);
+        }
+
+        return [true,$list];
+    }
+
+    public function warningEdit($data){
+        if(empty($data['id'])) return [false,'ID不能为空'];
+        Warning::where('id',$data['id'])->update(['state' => 1]);
+        return [true,''];
+    }
 }

+ 1 - 0
config/routemap.php

@@ -26,5 +26,6 @@ return [
         'api/screenDel' => '仓或台删除',
         'api/screenDevice' => '仓或台绑定设备',
         'api/screenRemoveDevice' => '仓或台移除设备',
+        'api/warningEdit' => '预警确认'
     ]
 ];

+ 4 - 0
routes/api.php

@@ -78,6 +78,10 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
 
     //操作日志
     $route->any('systemRecordList', 'Api\SystemRecordController@orderList');
+    //预警列表
+    $route->any('warningList', 'Api\SystemRecordController@warningList');
+    //改变预警状态
+    $route->any('warningEdit', 'Api\SystemRecordController@warningEdit');
 
     //暂时没用----------------------------
     //菜单