Browse Source

提交dist

shs 1 năm trước cách đây
mục cha
commit
737a404570

+ 3 - 3
aidex-admin/target/classes/application.yml

@@ -70,13 +70,13 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: 127.0.0.1
+    host: 192.168.1.243
     # 端口,默认为6379
-    port: 16379
+    port: 6379
     # 数据库索引
     database: 0
     # 密码
-    # password: 12345678
+    password: 12345678
     # 连接超时时间
     timeout: 10s
     lettuce:

+ 2 - 0
aidex-common/src/main/java/com/aidex/common/constant/Constants.java

@@ -190,6 +190,8 @@ public class Constants {
      */
     public static final String GPS_TOKEN_PREFIX = "gps_token:";
 
+    public static final String GPS_LOGIN_INFO_PREFIX = "gps_login_info:";
+
     /**
      * GPS_token 有效期(分钟)
      */

+ 6 - 0
aidex-controller/src/main/java/com/aidex/web/controller/gps/GpsController.java

@@ -30,6 +30,12 @@ public class GpsController extends BaseController {
     }
 
     @PreAuthorize("@ss.hasPermi('monit:gps:location')")
+    @GetMapping("/location/play")
+    public R<String> localtionPlay(String shipId) {
+        return R.data(gpsService.getPlayUrl(shipId));
+    }
+
+    @PreAuthorize("@ss.hasPermi('monit:gps:location')")
     @GetMapping("/location")
     public R<LocationEntity> localtion(String shipId) {
         return R.data(gpsService.getLocation(shipId));

+ 2 - 0
aidex-quartz/src/main/java/com/aidex/quartz/task/RefreshMdsTask.java

@@ -100,6 +100,8 @@ public class RefreshMdsTask {
 				if (jsonObjec.getBoolean("success")){
 					JSONObject token = jsonObjec.getJSONObject("data");
 					if (token != null && StringUtils.isNotEmpty(token.getString("mds"))){
+						redisCache.deleteKey(Constants.GPS_LOGIN_INFO_PREFIX);
+						redisCache.setCacheObject(Constants.GPS_LOGIN_INFO_PREFIX, token.toJSONString(), Constants.GPS_TOKEN_EXPIRATION, TimeUnit.MINUTES);
 						redisCache.deleteKey(Constants.GPS_TOKEN_PREFIX);
 						redisCache.setCacheObject(Constants.GPS_TOKEN_PREFIX, token.getString("mds"), Constants.GPS_TOKEN_EXPIRATION, TimeUnit.MINUTES);
 					}else {

+ 10 - 8
aidex-system/src/main/java/com/aidex/common/gps/common/GeneratorGspApi.java

@@ -21,23 +21,25 @@ public class GeneratorGspApi {
     private final String server = "/GetDataService.aspx";
     private final String mapServer = "/RouterPass.ashx";
 
-    public String GenerationMapUrl(String method,String macId,String mapType){
+    public String GenerationMapUrl(String mapType,String custName,String objectId,String userId){
         String mds = redisCache.getStringValue(Constants.GPS_TOKEN_PREFIX);
         Map<String, Object> parmas = new HashMap<>();
-        parmas.put("method",method);
         parmas.put("mds",mds);
-        parmas.put("macid",macId);
-        parmas.put("url","http://www.18gps.net/");
         parmas.put("mapType",mapType);
-
-        StringBuilder builder = new StringBuilder(apiHost);
-        builder.append(mapServer);
+        parmas.put("custname",custName);
+        parmas.put("objectid",objectId);
+        parmas.put("lang","cn");
+        parmas.put("requestSource","web");
+        parmas.put("custid",userId);
+        parmas.put("school_id",userId);
+        parmas.put("r",System.currentTimeMillis());
+
+        StringBuilder builder = new StringBuilder("http://www.18gps.net/user/playback.html");
         builder.append("?");
         builder.append(GeneratorParams(parmas));
         return builder.toString();
     }
 
-
     public Map<String, Object> GenerationParams(String method,String api){
         String mds = redisCache.getStringValue(Constants.GPS_TOKEN_PREFIX);
         Map<String, Object> parmas = new HashMap<>();

+ 5 - 0
aidex-system/src/main/java/com/aidex/common/gps/common/GpsApi.java

@@ -12,4 +12,9 @@ public interface GpsApi {
      * 批量查询单个定位信息
      * */
     String findLocationByBatch = "LocationBatch";
+
+    /*
+     * 批量查询单个定位信息
+     * */
+    String findDeviceInfo = "DeviceInfo";
 }

+ 30 - 0
aidex-system/src/main/java/com/aidex/common/gps/domain/DeviceEntity.java

@@ -0,0 +1,30 @@
+package com.aidex.common.gps.domain;
+
+import lombok.Data;
+
+@Data
+public class DeviceEntity {
+
+    private String objectid;
+    private String fullName;
+    private String iccid;
+    private String platenumber;
+    private String macid;
+    private String macName;
+    private String deviceRemark;
+    private String icon;
+    private String macVersion;
+    private String lat;
+    private String lon;
+    private String gpstime;
+    private String platformdate;
+    private String expiredate;
+    private String factorytime;
+    private String updtime;
+    private String hearttime;
+    private String activatetime;
+    private String contact;
+    private String phone;
+    private String speedingValue;
+    private String speedingDuration;
+}

+ 2 - 0
aidex-system/src/main/java/com/aidex/common/gps/server/IGpsService.java

@@ -8,6 +8,8 @@ public interface IGpsService {
 
     String getLocationUrl(String ShipId);
 
+    String getPlayUrl(String ShipId);
+
     LocationEntity getLocation(String shipId);
 
     List<LocationEntity> getLocationBatch();

+ 17 - 1
aidex-system/src/main/java/com/aidex/common/gps/server/impl/GpsService.java

@@ -1,13 +1,17 @@
 package com.aidex.common.gps.server.impl;
 
+import com.aidex.common.constant.Constants;
+import com.aidex.common.core.redis.RedisCache;
 import com.aidex.common.gps.common.GeneratorGspApi;
 import com.aidex.common.gps.common.GpsApi;
 import com.aidex.common.gps.common.GpsRequest;
+import com.aidex.common.gps.domain.DeviceEntity;
 import com.aidex.common.gps.domain.LocationEntity;
 import com.aidex.common.gps.server.IGpsService;
 import com.aidex.system.domain.SysShip;
 import com.aidex.system.service.SysShipService;
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,11 +29,23 @@ public class GpsService implements IGpsService {
     private GpsRequest gpsRequest;
     @Autowired
     private SysShipService sysShipService;
+    @Autowired
+    private RedisCache redisCache;
 
 
     public String getLocationUrl(String shipId){
         SysShip sysShip = sysShipService.get(shipId);
-        return generatorGspApi.GenerationMapUrl(GeneratorGspApi.RquestMethod.follow,sysShip.getGpsDeviceNum(), GeneratorGspApi.GpsMapType.QQ);
+        return "";
+//        return generatorGspApi.GenerationMapUrl(GeneratorGspApi.RquestMethod.follow,sysShip.getShipNum(), GeneratorGspApi.GpsMapType.QQ);
+    }
+
+    public String getPlayUrl(String shipId){
+        SysShip sysShip = sysShipService.get(shipId);
+        String userInfo = redisCache.getStringValue(Constants.GPS_LOGIN_INFO_PREFIX);
+        Map<String, Object> params = generatorGspApi.GeneratorQueryParams(GpsApi.findDeviceInfo);
+        params.put("macid",sysShip.getShipNum());
+        DeviceEntity deviceEntity = gpsRequest.post(params).toJavaObject(DeviceEntity.class);
+        return generatorGspApi.GenerationMapUrl(GeneratorGspApi.GpsMapType.QQ,sysShip.getShipNanme(),deviceEntity.getObjectid(), JSONObject.parse(userInfo).getString("id"));
     }
 
     public LocationEntity getLocation(String shipId){

+ 24 - 0
aidex-system/src/main/java/com/aidex/common/utils/dist/CalcDist.java

@@ -0,0 +1,24 @@
+package com.aidex.common.utils.dist;
+
+public class CalcDist {
+
+    public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
+        double earthRadius = 6378137; // 地球半径,单位为米
+
+        double lat1Rad = Math.toRadians(lat1);
+        double lon1Rad = Math.toRadians(lon1);
+        double lat2Rad = Math.toRadians(lat2);
+        double lon2Rad = Math.toRadians(lon2);
+
+        double deltaLat = lat2Rad - lat1Rad;
+        double deltaLon = lon2Rad - lon1Rad;
+
+        double a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
+                Math.cos(lat1Rad) * Math.cos(lat2Rad) *
+                        Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
+        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+
+        double distance = earthRadius * c;
+        return distance;
+    }
+}

+ 1 - 0
aidex-system/src/main/java/com/aidex/framework/cache/MyInitializer.java

@@ -57,6 +57,7 @@ public class MyInitializer {
 				JSONObject jsonObjec = JSONObject.parseObject(result);
 				if (jsonObjec.getBoolean("success")){
 					JSONObject token = jsonObjec.getJSONObject("data");
+					redisCache.setCacheObject(Constants.GPS_LOGIN_INFO_PREFIX, token.toJSONString(), Constants.GPS_TOKEN_EXPIRATION, TimeUnit.MINUTES);
 					if (token != null && StringUtils.isNotEmpty(token.getString("mds"))){
 						redisCache.setCacheObject(Constants.GPS_TOKEN_PREFIX, token.getString("mds"), Constants.GPS_TOKEN_EXPIRATION, TimeUnit.MINUTES);
 					}else {

+ 33 - 0
aidex-ui/public/gps.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="zh-cmn-Hans">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <title>当前位置</title>
+  </head>
+  <style>
+    body {
+      width: 100%;
+      height: 100vh;
+    }
+  </style>
+  <body>
+    <iframe
+    frameborder="0"
+    id="locationIframe"
+    width="100%"
+    height="100%"
+    src="http://openapi.18gps.net/RouterPass.ashx?method=Playback&macid=17018458028&mapType=QQ&mds=320ed22d30df445283e10bcf40221f38&url=http://www.18gps.net/" ></iframe>
+  </body>
+
+  <script>
+    // function load() {
+    //   const iframe = document.createElement("locationIframe");
+    //   iframe.contentWindow.postMessage("当前位置", "http://localhost");
+    //   window.onmessage = e => {
+    //     console.log(e.data);
+    //   };
+    // }
+  </script>
+</html>

+ 9 - 0
aidex-ui/src/api/gps/gps.js

@@ -16,3 +16,12 @@ export function locationBatch () {
     method: 'get'
   })
 }
+
+// 获取全部设备定位地点
+export function locationPlay (query) {
+  return request({
+    url: '/monit/gps/location/play',
+    method: 'get',
+    params: query
+  })
+}

+ 101 - 0
aidex-ui/src/views/operation/track/index.vue

@@ -0,0 +1,101 @@
+<template>
+  <div ref="content">
+    <a-card :bordered="false">
+      <a-page-header style="border-bottom: 1px solid rgb(235, 237, 240); padding: 8px 16px" title="" />
+      <split splitHeight="100%" leftWidth="220">
+        <template slot="paneL">
+          <ship-tree
+            ref="shipTree"
+            :shipOptions="shipOptions"
+            @select="clickNode"
+          />
+        </template>
+        <template slot="paneR">
+          <div class="table-page-search-wrapper">
+            <h2>{{ selShipData.shipNanme?selShipData.shipNanme:'' }}-轨迹回放</h2>
+          </div>
+          <a-divider />
+
+          <iframe width="100%" style="height: calc(100% - 65px);border:none;padding: 0;margin: 0;" :src="gpsPlayUrl"></iframe>
+        </template>
+      </split>
+    </a-card>
+  </div>
+</template>
+
+<script>
+import { listAllSysShip } from '@/api/system/sysShip'
+import { locationPlay } from '@/api/gps/gps'
+import ShipTree from './modules/ShipTree'
+import Split from '@/components/pt/split/Index'
+
+export default {
+  name: 'TencentMapLocation',
+  components: {
+    Split,
+    ShipTree
+  },
+  data() {
+    return {
+      selShipData: {},
+      shipOptions: [],
+      gpsPlayUrl: ''
+    }
+  },
+  filters: {},
+  created() {
+    this.getTreeselect()
+  },
+  computed: {},
+  watch: {},
+  methods: {
+    getPlayUrl() {
+      locationPlay({ shipId: this.selShipData.id }).then(res => {
+        this.gpsPlayUrl = res.data
+      })
+    },
+    /** 查询部门下拉树结构 */
+    getTreeselect() {
+      listAllSysShip().then((response) => {
+        this.shipOptions = response.data
+        this.selShipData = this.shipOptions[0]
+        this.getPlayUrl()
+      })
+    },
+    clickNode(node) {
+      var selectItem = node.$options.propsData.dataRef
+      if (this.selShipData.id !== selectItem.id) {
+        this.selShipData = node.$options.propsData.dataRef
+        this.getPlayUrl()
+      }
+    }
+  }
+}
+</script>
+<style lang="less" scoped>
+.ant-divider-horizontal {
+  margin: 0;
+  background: rgb(235, 237, 240);
+}
+.demo-split {
+  height: 200px;
+}
+.demo-split-pane {
+  padding: 10px;
+}
+.ant-avatar {
+  font-size: 12px;
+  border-radius: 4px;
+  vertical-align: middle;
+  margin-right: 8px;
+}
+</style>
+<style>
+.location_info{
+  width: 130px;
+}
+.location_info p{
+  margin: 0;
+  padding: 0;
+}
+</style>

+ 152 - 0
aidex-ui/src/views/operation/track/modules/ShipTree.vue

@@ -0,0 +1,152 @@
+<template>
+  <div>
+    <!-- <a-input-search style="margin-bottom: 8px" placeholder="输入名称回车查询" @search="filterNode" /> -->
+    <a-tree
+      v-if="shipOptions.length > 0"
+      :tree-data="shipOptions"
+      :replaceFields="replaceFields"
+      :default-expanded-keys="expandedKeys"
+      :expanded-keys="expandedKeys"
+      :auto-expand-parent="autoExpandParent"
+      showIcon
+      @select="handleNodeClick"
+      @expand="onExpand"
+    >
+    </a-tree></div>
+</template>
+<script>
+  import allIcon from '@/core/icons'
+const getParentKey = (id, tree) => {
+  let parentKey
+  for (let i = 0; i < tree.length; i++) {
+    const node = tree[i]
+    if (node.children) {
+      if (node.children.some(item => item.id === id)) {
+        parentKey = node.id
+      } else if (getParentKey(id, node.children)) {
+        parentKey = getParentKey(id, node.children)
+      }
+    }
+  }
+  return parentKey
+}
+export default {
+  name: 'ShipTree',
+  props: {
+    shipOptions: {
+          type: Array,
+          required: true
+        },
+    defalutExpandedKeys: {
+          type: Array
+        }
+  },
+  components: {
+    allIcon
+  },
+  data () {
+    return {
+      expandedKeys: this.defalutExpandedKeys,
+      oldShipOptions: [], // 记录查询前数据结构
+      oldExpandedKeys: [],
+      allIcon,
+      replaceFields: { children: 'children', key: 'id', title: 'shipNanme' },
+      shipNodes: [],
+      searchValue: '',
+      autoExpandParent: true
+    }
+  },
+  filters: {
+  },
+  created () {
+  },
+  computed: {
+  },
+  watch: {
+  },
+  methods: {
+    getAllShipNode (nodes) {
+      if (!nodes || nodes.length === 0) {
+        return []
+      }
+      nodes.forEach(node => {
+        this.shipNodes.push({ id: node.id, label: node.label })
+        return this.getAllShipNode(node.children)
+      })
+    },
+    getExpandedKeys (nodes) {
+     if (!nodes || nodes.length === 0) {
+       return []
+     }
+        // 最后一层不展开
+        nodes.forEach(node => {
+        this.shipNodes.push(node.id)
+        return this.getExpandedKeys(node.children)
+        })
+    },
+    // 筛选节点
+    filterNode (value, e) {
+      if (this.oldShipOptions.length === 0) {
+       this.oldShipOptions = this.shipOptions
+       this.oldExpandedKeys = this.expandedKeys
+      }
+      if (value.trim() === '') {
+        // 触发父页面设置树数据
+          this.$emit('setDataOptionInfo', this.oldShipOptions)
+          Object.assign(this, {
+            expandedKeys: this.oldExpandedKeys,
+            searchValue: value,
+            autoExpandParent: true
+          })
+     } else {
+      //  const searchInfo = { shipName: value }
+      //  searchShip(searchInfo).then(response => {
+      //    // 触发父页面设置树数据
+      //     this.$emit('setDataOptionInfo', response.data)
+      //     // this.searchTree(value, response.data)
+      //     this.getExpandedKeys(response.data)
+      //    Object.assign(this, {
+      //      expandedKeys: this.shipNodes,
+      //      searchValue: value,
+      //      autoExpandParent: true
+      //    })
+      //    this.shipNodes = []
+      //  })
+     }
+    },
+    // 节点单击事件,
+    handleNodeClick (keys, event) {
+      this.$emit('select', event.node)
+    },
+    onExpand (expandedKeys) {
+      this.expandedKeys = expandedKeys
+      this.autoExpandParent = false
+    },
+    searchTree (value, options) {
+      this.getAllShipNode(options)
+      console.log('shipNodes', this.shipNodes)
+      const gData = options
+      const expandedKeys = this.shipNodes
+        .map(item => {
+          if (item.label.indexOf(value) > -1) {
+            return getParentKey(item.id, gData)
+          }
+          return null
+        })
+        .filter((item, i, self) => item && self.indexOf(item) === i)
+      Object.assign(this, {
+        expandedKeys: expandedKeys,
+        searchValue: value,
+        autoExpandParent: true
+      })
+      this.shipNodes = []
+    }
+  }
+}
+</script>
+<style lang="less">
+  .depIcon {
+    color: #2f54eb;
+     font-size: 20px;
+  }
+</style>