소스 검색

增加在线判断

shs 1 년 전
부모
커밋
d114af0228

BIN
.DS_Store


+ 4 - 4
aidex-admin/src/main/resources/application.yml

@@ -70,13 +70,13 @@ spring:
   # redis 配置
   redis:
     # 地址
-    host: 182.150.25.30
+    host: 192.168.1.243
     # 端口,默认为6379
-    port: 2212
+    port: 6379
     # 数据库索引
     database: 0
     # 密码
-    password: Shs2514
+    password: 12345678
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -123,7 +123,7 @@ pagehelper:
 # Swagger配置
 swagger:
   # 是否开启swagger
-  enabled: true
+  enabled: false
   # 请求前缀
   pathMapping: /api
 

+ 11 - 1
aidex-controller/src/main/java/com/aidex/web/controller/app/AppController.java

@@ -63,11 +63,21 @@ public class AppController {
             @ApiImplicitParam(name = "direction", value = "正向(TRUE)/反向(FALSE)、默认正向", required = true, dataType = "Boolean"),
             @ApiImplicitParam(name = "lat", value = "纬度", required = true, dataType = "String"),
             @ApiImplicitParam(name = "lon", value = "经度", required = true, dataType = "String")})
-    public R<LocationVO> getLocationAll(@RequestParam(defaultValue = "true", name = "direction") Boolean direction,@RequestParam(defaultValue = "",name = "lat") String lat, @RequestParam(defaultValue = "",name = "lon") String lon )
+    public R<LocationVO> getLocation(@RequestParam(defaultValue = "true", name = "direction") Boolean direction,@RequestParam(defaultValue = "",name = "lat") String lat, @RequestParam(defaultValue = "",name = "lon") String lon )
     {
         return R.data(iAppService.findAllLocationByNext(direction,lat,lon));
     }
 
+
+    @GetMapping("/location/all")
+    @ApiOperation(value = "获取全部船只位置", notes = "获取全部船只位置", produces = "application/json")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "direction", value = "正向(TRUE)/反向(FALSE)、默认正向", required = true, dataType = "Boolean")})
+    public R<List<LocationEntity>> getLocationAll(@RequestParam(defaultValue = "true", name = "direction") Boolean direction)
+    {
+        return R.data(iAppService.findAllLocation(direction));
+    }
+
     @GetMapping("/wharf/my")
     @ApiOperation(value = "获取离我最近的站点及距离", notes = "获取离我最近的站点及距离", produces = "application/json")
     @ApiImplicitParams({

+ 4 - 0
aidex-system/src/main/java/com/aidex/common/app/domain/vo/LocationVO.java

@@ -18,4 +18,8 @@ public class LocationVO extends LocationEntity {
     private Double distance;
     @ApiModelProperty(value="等待时间",required=true)
     private Long awaitTime;
+    @ApiModelProperty(value="剩余座位数量",required=true)
+    private Long reseat;
+    @ApiModelProperty(value="距离几站",required=true)
+    private Long distSiteNum;
 }

+ 1 - 1
aidex-system/src/main/java/com/aidex/common/app/server/IAppService.java

@@ -18,7 +18,7 @@ public interface IAppService {
 
     List<SysWharf> findSysWharfList();
 
-    List<LocationVO> findAllLocation(Boolean direction);
+    List<LocationEntity> findAllLocation(Boolean direction);
 
     LocationVO findAllLocationByNext(Boolean direction,String lat, String lon);
 

+ 65 - 17
aidex-system/src/main/java/com/aidex/common/app/server/impl/AppService.java

@@ -6,6 +6,7 @@ import com.aidex.common.app.server.IAppService;
 import com.aidex.common.exception.SysException;
 import com.aidex.common.gps.domain.FenceEntity;
 import com.aidex.common.gps.domain.LocationEntity;
+import com.aidex.common.gps.domain.MyGpsEntity;
 import com.aidex.common.gps.server.IGpsService;
 import com.aidex.common.utils.StringUtils;
 import com.aidex.common.utils.dist.CalcDist;
@@ -19,6 +20,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.*;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
@@ -57,17 +59,17 @@ public class AppService implements IAppService {
     /*
     * direction 方向 true正向 false反向
     * */
-    public List<LocationVO> findAllLocation(Boolean direction){
+    public List<LocationEntity> findAllLocation(Boolean direction){
         // 全部船只信息
         List<LocationEntity> locationEntities = iGpsService.getLocationBatch();
         if(locationEntities.size() <= 0)
             throw new SysException(8821,"暂无运行船只");
 
         // 返回结果
-        List<LocationVO> locationList = new ArrayList<>();
+//        List<LocationVO> locationList = new ArrayList<>();
 
         // 停靠速度
-        Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
+//        Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
 
         // 正反向计算数据
         List<LocationEntity> calcList = new ArrayList<>();
@@ -85,17 +87,17 @@ public class AppService implements IAppService {
             conditions = ConfigUtils.getConfigByKey("reverse.direction").getConfigValue().split("-");
             calcList = locationEntities.stream().filter(local -> ((Double.valueOf(local.getDir()) >= Double.valueOf(conditions[0])) && (Double.valueOf(local.getDir()) <= Double.valueOf(conditions[1])))).collect(Collectors.toList());
         }
-        for (LocationEntity locationEntity : calcList ) {
-            LocationVO locationVO = new LocationVO();
-            BeanUtils.copyProperties(locationEntity,locationVO);
-            locationVO.setIsArrival(Boolean.FALSE);
-            // 查询全部停止船只判断是否到站
-            if(Integer.valueOf(locationVO.getSpeed()) <= stopSpeed){
-                locationVO.setIsArrival(Boolean.TRUE);
-            }
-            locationList.add(locationVO);
-        }
-        return locationList;
+//        for (LocationEntity locationEntity : calcList ) {
+//            LocationVO locationVO = new LocationVO();
+//            BeanUtils.copyProperties(locationEntity,locationVO);
+//            locationVO.setIsArrival(Boolean.FALSE);
+//            // 查询全部停止船只判断是否到站
+//            if(Integer.valueOf(locationVO.getSpeed()) <= stopSpeed){
+//                locationVO.setIsArrival(Boolean.TRUE);
+//            }
+//            locationList.add(locationVO);
+//        }
+        return  calcList;
     }
 
 
@@ -103,10 +105,38 @@ public class AppService implements IAppService {
         if(StringUtils.isEmpty(lat) || StringUtils.isEmpty(lon))
             throw new SysException(4441,"请告诉我你在哪");
         // 全部船只信息
-        List<LocationEntity> locationEntities = iGpsService.getLocationBatch();
+        List<MyGpsEntity> allMyGps = iGpsService.findMyGps();
+        // 全部在线设备
+        String macIds = allMyGps.stream().filter(gps -> gps.getStatus().equals("1")).map(MyGpsEntity::getMacid).collect(Collectors.joining(","));
+        List<LocationEntity> locationEntities = iGpsService.getLocationBatchByMac(macIds);
+
+
         if(locationEntities.size() <= 0)
             throw new SysException(8821,"暂无运行船只");
 
+        // 默认到站停留时间
+        Integer inStopTime = Integer.valueOf(ConfigUtils.getConfigByKey("pull.in.time").getConfigValue());
+
+        for (LocationEntity locationEntity : locationEntities) {
+            if(Double.valueOf(locationEntity.getDir()) <= 0){
+                // 获取当天的 LocalDate 对象
+                LocalDate today = LocalDate.now();
+                // 获取当天的开始时间
+                LocalDateTime startOfDay = today.atStartOfDay();
+                // 获取当天的结束时间
+                LocalDateTime endOfDay = LocalDateTime.of(today, LocalTime.MAX);
+                // 转换为时间戳
+                long startTimestamp = startOfDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+                long endTimestamp = endOfDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+                List<FenceEntity> fence = iGpsService.findFenceInByMacId(locationEntity.getMacid(),startTimestamp,endTimestamp);
+                if(fence.size() > 0){
+                    // 取最新数据
+                    FenceEntity fenceEntity = fence.get(0);
+                    locationEntity.setDir(fenceEntity.getDir());
+                }
+            }
+        }
+
         // 正反向计算数据
         List<LocationVO> calcList = new ArrayList<>();
         // 停靠速度
@@ -169,8 +199,7 @@ public class AppService implements IAppService {
                 return null;
             // 停靠时间
             Long awaitTime = 0L;
-            // 默认到站停留时间
-            Integer inStopTime = Integer.valueOf(ConfigUtils.getConfigByKey("pull.in.time").getConfigValue());
+
 
             // 离船最近的站点
             SysWharf wharfShip = this.findNearestStation(res.getLat(),res.getLon());
@@ -186,6 +215,25 @@ public class AppService implements IAppService {
             List<FenceEntity> fenceShipEntities = iGpsService.findFenceIn(res.getMacid(),wharfShip.getWharfNanme(),startTime,endTime);
             res.setMyWharf(wharf);
 
+            Long distSiteNum = 0L;
+            if(direction){
+                Double position = CalcDist.gps2d(Double.valueOf(wharfShip.getLat()),Double.valueOf(wharfShip.getLng()),Double.valueOf(res.getLat()),Double.valueOf(res.getLon()));
+                if(position <= 0){
+                   distSiteNum = (wharf.getWharfOrder() / 10) - (wharfShip.getWharfOrder() / 10) ;
+                }else {
+                   distSiteNum = (wharf.getWharfOrder() / 10) - ((wharfShip.getWharfOrder() / 10) + 1);
+                }
+            }else {
+                Double position = CalcDist.gps2d(Double.valueOf(res.getLat()),Double.valueOf(res.getLon()),Double.valueOf(wharfShip.getLat()),Double.valueOf(wharfShip.getLng()));
+                if(position <= 0){
+                    distSiteNum = (wharfShip.getWharfOrder() / 10) - (wharf.getWharfOrder() / 10) ;
+                }else {
+                    distSiteNum = ((wharfShip.getWharfOrder() / 10) - 1) - (wharf.getWharfOrder() / 10) ;
+                }
+            }
+
+            res.setDistSiteNum(distSiteNum);
+
             // 船只已经停靠入站离我最近的站
             if (isStopOperation && (fenceEntities.size() > 0 || fenceShipEntities.size() > 0)) {
                 res.setStopWharf(wharfShip);

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

@@ -35,7 +35,7 @@ public class GeneratorGspApi {
         parmas.put("loginUrl","");
         parmas.put("r",System.currentTimeMillis());
 
-        StringBuilder builder = new StringBuilder("http://www.18gps.net/user/playback.html");
+        StringBuilder builder = new StringBuilder("https://www.18gps.net/user/playback.html");
         builder.append("?");
         builder.append(GeneratorParams(parmas));
         return builder.toString();

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

@@ -14,6 +14,11 @@ public interface GpsApi {
     String findLocationByBatch = "LocationBatch";
 
     /*
+     * 获取ACC状态
+     * */
+    String findAcc = "ACCRecord";
+
+    /*
      * 批量查询单个定位信息
      * */
     String findDeviceInfo = "DeviceInfo";
@@ -29,4 +34,9 @@ public interface GpsApi {
      * */
     String fenceRecord = "FenceRecord";
 
+    /*
+     * 查询我的设备
+     * */
+    String findUserDevices = "UserDevices";
+
 }

+ 14 - 0
aidex-system/src/main/java/com/aidex/common/gps/domain/AccEntity.java

@@ -0,0 +1,14 @@
+package com.aidex.common.gps.domain;
+
+import lombok.Data;
+
+@Data
+public class AccEntity {
+
+    private String macid;
+    private String accState;
+    private String startTime;
+    private String endTime;
+    private String duration;
+    private String second;
+}

+ 23 - 0
aidex-system/src/main/java/com/aidex/common/gps/domain/MyGpsEntity.java

@@ -0,0 +1,23 @@
+package com.aidex.common.gps.domain;
+
+import lombok.Data;
+
+@Data
+public class MyGpsEntity {
+
+    private String objectid;
+    private String platenumber;
+    private String fullName;
+    private String macid;
+    private String blockdate;
+    private String status;
+    private String speed;
+    private String updtime;
+    private String defenceStatus;
+    private String gpstime;
+    private String sim;
+    private String server_time;
+    private String macName;
+    private String gsm;
+    private String gpsCount;
+}

+ 9 - 3
aidex-system/src/main/java/com/aidex/common/gps/server/IGpsService.java

@@ -1,8 +1,6 @@
 package com.aidex.common.gps.server;
 
-import com.aidex.common.gps.domain.FenceEntity;
-import com.aidex.common.gps.domain.LocationEntity;
-import com.aidex.common.gps.domain.MileageEntity;
+import com.aidex.common.gps.domain.*;
 
 import java.util.List;
 
@@ -16,7 +14,15 @@ public interface IGpsService {
 
     List<LocationEntity> getLocationBatch();
 
+    List<LocationEntity> getLocationBatchByMac(String macIds);
+
     List<MileageEntity> getMileageStatisics(String startTime, String endTime);
 
     List<FenceEntity> findFenceIn(String macId, String fenceName, Long startTime, Long endTime);
+
+    List<FenceEntity> findFenceInByMacId(String macId,Long startTime, Long endTime);
+
+    List<MyGpsEntity> findMyGps();
+
+    List<AccEntity> findAccByMacId(String macId, Long startTime, Long endTime);
 }

+ 38 - 4
aidex-system/src/main/java/com/aidex/common/gps/server/impl/GpsService.java

@@ -5,10 +5,7 @@ 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.FenceEntity;
-import com.aidex.common.gps.domain.LocationEntity;
-import com.aidex.common.gps.domain.MileageEntity;
+import com.aidex.common.gps.domain.*;
 import com.aidex.common.gps.server.IGpsService;
 import com.aidex.common.utils.StringUtils;
 import com.aidex.system.domain.SysShip;
@@ -72,6 +69,14 @@ public class GpsService implements IGpsService {
          return locationEntities;
     }
 
+    public List<LocationEntity> getLocationBatchByMac(String macIds){
+        Map<String, Object> params = generatorGspApi.GeneratorQueryParams(GpsApi.findLocationByBatch);
+        params.put("macids",macIds);
+        params.put("mapType", GeneratorGspApi.GpsMapType.QQ);
+        List<LocationEntity> locationEntities = gpsRequest.postArray(params).toJavaList(LocationEntity.class);
+        return locationEntities;
+    }
+
     public List<MileageEntity> getMileageStatisics(String startTime,String endTime){
         Long startOfDay, endOfDay ;
         if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){
@@ -103,4 +108,33 @@ public class GpsService implements IGpsService {
         return fenceEntities;
     }
 
+
+    public List<FenceEntity> findFenceInByMacId(String macId,Long startTime, Long endTime){
+        Map<String, Object> params = generatorGspApi.GeneratorQueryParams(GpsApi.findLocationByBatch);
+        params.put("fenceType",1);
+        params.put("mapType", GeneratorGspApi.GpsMapType.QQ);
+        params.put("macid", macId);
+        params.put("startTime", startTime);
+        params.put("endTime", endTime);
+        List<FenceEntity> fenceEntities = gpsRequest.postArray(params).toJavaList(FenceEntity.class);
+        return fenceEntities;
+    }
+
+
+    public List<AccEntity> findAccByMacId(String macId, Long startTime, Long endTime){
+        Map<String, Object> params = generatorGspApi.GeneratorQueryParams(GpsApi.findAcc);
+        params.put("macid", macId);
+        params.put("startTime", startTime);
+        params.put("endTime", endTime);
+        params.put("accState", "1");
+        List<AccEntity> accEntities = gpsRequest.postArray(params).toJavaList(AccEntity.class);
+        return accEntities;
+    }
+
+    public List<MyGpsEntity> findMyGps(){
+        Map<String, Object> params = generatorGspApi.GeneratorQueryParams(GpsApi.findUserDevices);
+        List<MyGpsEntity> myG = gpsRequest.postArray(params).toJavaList(MyGpsEntity.class);
+        return myG;
+    }
+
 }

+ 1 - 0
aidex-ui/node

@@ -0,0 +1 @@
+all_version/node-v16.19.0-darwin-x64

+ 7 - 7
aidex-ui/package.json

@@ -12,14 +12,14 @@
   },
   "dependencies": {
     "ant-design-vue": "1.7.2",
-    "axios": "^0.19.0",
+    "axios": "^1.6.8",
     "core-js": "^3.1.2",
     "echarts": "^5.0.0",
     "enquire.js": "^2.1.6",
     "highlight.js": "^10.5.0",
     "lodash.clonedeep": "^4.5.0",
     "lodash.get": "^4.4.2",
-    "lodash.pick": "^4.4.0",
+    "lodash.pick": "^3.1.0",
     "md5": "^2.2.1",
     "mockjs2": "1.0.8",
     "moment": "^2.24.0",
@@ -42,12 +42,12 @@
   },
   "devDependencies": {
     "@ant-design/colors": "^3.2.1",
-    "@vue/cli-plugin-babel": "^4.0.4",
-    "@vue/cli-plugin-eslint": "^4.0.4",
-    "@vue/cli-plugin-router": "^4.0.4",
-    "@vue/cli-plugin-unit-jest": "^4.0.4",
+    "@vue/cli-plugin-babel": "^5.0.8",
+    "@vue/cli-plugin-eslint": "^5.0.8",
+    "@vue/cli-plugin-router": "^5.0.8",
+    "@vue/cli-plugin-unit-jest": "^5.0.8",
     "@vue/cli-plugin-vuex": "^4.0.4",
-    "@vue/cli-service": "^4.0.4",
+    "@vue/cli-service": "^3.3.1",
     "@vue/eslint-config-standard": "^4.0.0",
     "@vue/test-utils": "^1.0.0-beta.29",
     "babel-eslint": "^10.0.1",

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

@@ -1,33 +0,0 @@
-<!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>

+ 5 - 5
aidex-ui/src/views/user/Login.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="main">
-<!--    <a-icon class="QRcodeIcon" :component="allIcon.QRcodeIcon"/>-->
+    <!--    <a-icon class="QRcodeIcon" :component="allIcon.QRcodeIcon"/>-->
     <a-form-model id="formLogin" ref="form" class="user-layout-login" :model="form" :rules="rules">
       <a-page-header title="用户登录" />
       <a-form-model-item prop="username">
@@ -25,7 +25,7 @@
           <img class="getCaptcha" :src="codeUrl" @click="getCode">
         </a-col>
       </a-row>
-<!--      <a-form-item>
+      <!--      <a-form-item>
         <a-checkbox v-decorator="['rememberMe', { valuePropName: 'checked' }]">记住密码</a-checkbox>
         <div style="float: right;line-height: 30px;">
           还没有账号?<a-button type="link" >立即注册</a-button>
@@ -43,7 +43,7 @@
           @click="handleSubmit"
         >确定</a-button>
       </a-form-item>
-<!--      <a-space>
+      <!--      <a-space>
         <div style="margin-top: -10px;">其它登录方式</div>
         <div class="icons-list">
           <a-icon class="dingtalk" :component="allIcon.dingtalkIcon"/>
@@ -74,8 +74,8 @@ export default {
       allIcon,
       codeUrl: '',
       form: {
-        username: 'admin',
-        password: 'admin123',
+        username: '',
+        password: '',
         code: undefined,
         uuid: ''
       },