tongshanglei 2 years ago
parent
commit
a1f9a5c977

+ 1 - 0
catch/device/model/Device.php

@@ -96,4 +96,5 @@ class Device extends Model
             ->select();
         return $res;
     }
+   
 }

+ 41 - 0
catch/hydraulic/database/migrations/20220504142809_hydraulic_add_Fields.php

@@ -0,0 +1,41 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+
+class HydraulicAddFields extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        if ($this->hasTable('hydraulic')) {
+            $table = $this->table('hydraulic');
+
+            $table  ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
+                    ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
+                    ->update();
+        }
+      
+    }
+}

+ 22 - 0
catch/hydraulic/model/Hydraulic.php

@@ -59,6 +59,17 @@ class Hydraulic extends Model
         return $res;
     }
      /**
+     * 获取轨迹地图列表定位不分页 只查询有定位时间的
+     */
+    public function queryLocationList()
+    {
+        $res = $this->dataRange()
+                    ->catchSearch()
+                   
+                    ->select();
+        return $res;
+    }
+     /**
      * 获取导入用户(文本)
      */
     public function getCreatorUserAttr($value)
@@ -76,6 +87,17 @@ class Hydraulic extends Model
         return Db::table('departments')->where('id', $id)->value('department_name');
     }
     /**
+     * 获取部门名称(文本)
+     */
+    public function getOnlineTimeAttr($value)
+    {
+       if($value){
+            return date('Y-m-d H:i:s',$value);
+       }else{
+           return '-';
+       }
+    }
+    /**
      * 获取告警状态文本
      */
     public function getAlarmStateTextAttr($value)

+ 4 - 29
catch/map/controller/RouteMap.php

@@ -7,7 +7,8 @@ use catcher\CatchResponse;
 use catcher\base\CatchController;
 use Aliyun\OTS\OTSClient;
 
-use catchAdmin\device\model\Device as deviceModel;
+
+use catchAdmin\hydraulic\model\Hydraulic as deviceModel;
 use catchAdmin\fences\model\Fences as fencesModel;
 use think\facade\Db;
 use think\facade\Env;
@@ -55,25 +56,7 @@ class RouteMap extends CatchController
         // var_dump($list);
         return CatchResponse::success($list);
     }
-    /**
-     * 查询告警列表
-     * @time 2021年05月24日
-     * @return \think\response\Json
-     */
-    public function queryAlarmList(Request $request): \think\Response
-    {
-        $list=$this->deviceModel->queryAlarmList();
-
-
-        foreach($list as &$item){
-            if($item['online_time']<$item['wifi_online_time']){
-                $item['longitude']=$item['wifi_longitude'];
-                $item['latitude']=$item['wifi_latitude'];
-            }
-           
-        }
-        return CatchResponse::paginate($list);
-    }
+    
     /**
      *
      * @time  2021年05月24日
@@ -84,15 +67,7 @@ class RouteMap extends CatchController
         return CatchResponse::success($this->deviceModel->queryLocationList());
     }
     
-    /**
-     *
-     * @time  2021年05月24日
-     * @return \think\response\Json
-     */
-    public function queryAlarmLocationList(Request $request): \think\Response
-    {
-        return CatchResponse::success($this->deviceModel->queryAlarmLocationList());
-    }
+    
     
     
     /**