Quellcode durchsuchen

船只到站信息完成

shs vor 1 Jahr
Ursprung
Commit
253d4202c8

+ 8 - 2
aidex-controller/src/main/java/com/aidex/web/controller/app/AppController.java

@@ -1,6 +1,7 @@
 package com.aidex.web.controller.app;
 
 
+import com.aidex.common.app.domain.vo.LocationVO;
 import com.aidex.common.app.domain.vo.SysWharfVO;
 import com.aidex.common.app.server.IAppService;
 import com.aidex.common.core.domain.R;
@@ -58,13 +59,18 @@ public class AppController {
 
     @GetMapping("/location")
     @ApiOperation(value = "获取全部船只位置", notes = "获取全部船只位置", produces = "application/json")
-    public R<List<LocationEntity>> getLocationAll()
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "direction", value = "正向(TRUE)/反向(FALSE)、默认正向", required = true, dataType = "Boolean", paramType = "query")})
+    public R<List<LocationVO>> getLocationAll(@RequestParam(defaultValue = "true", name = "direction") Boolean direction)
     {
-        return R.data(iAppService.findAllLocation());
+        return R.data(iAppService.findAllLocation(direction));
     }
 
     @GetMapping("/wharf/my")
     @ApiOperation(value = "获取离我最近的站点及距离", notes = "获取离我最近的站点及距离", produces = "application/json")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "lat", value = "纬度", required = true, dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "lon", value = "经度", required = true, dataType = "String", paramType = "query")})
     public R<List<SysWharfVO>> getWharfMy(@RequestParam(defaultValue = "",name = "lat") String lat, @RequestParam(defaultValue = "",name = "lon") String lon )
     {
         return R.data(iAppService.findNearestStation(lat,lon));

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

@@ -0,0 +1,12 @@
+package com.aidex.common.app.domain.vo;
+
+import com.aidex.common.gps.domain.LocationEntity;
+import com.aidex.system.domain.SysWharf;
+import lombok.Data;
+
+@Data
+public class LocationVO extends LocationEntity {
+
+    private Boolean isArrival;
+    private SysWharf wharf;
+}

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

@@ -1,5 +1,6 @@
 package com.aidex.common.app.server;
 
+import com.aidex.common.app.domain.vo.LocationVO;
 import com.aidex.common.app.domain.vo.SysWharfVO;
 import com.aidex.common.gps.domain.LocationEntity;
 import com.aidex.system.domain.SysNotice;
@@ -17,7 +18,7 @@ public interface IAppService {
 
     List<SysWharf> findSysWharfList();
 
-    List<LocationEntity> findAllLocation();
+    List<LocationVO> findAllLocation(Boolean direction);
 
     List<SysWharfVO> findNearestStation(String lat, String lng);
 }

+ 93 - 5
aidex-system/src/main/java/com/aidex/common/app/server/impl/AppService.java

@@ -1,19 +1,19 @@
 package com.aidex.common.app.server.impl;
 
+import com.aidex.common.app.domain.vo.LocationVO;
 import com.aidex.common.app.domain.vo.SysWharfVO;
 import com.aidex.common.app.server.IAppService;
 import com.aidex.common.exception.SysException;
-import com.aidex.common.gps.common.GeneratorGspApi;
 import com.aidex.common.gps.domain.LocationEntity;
 import com.aidex.common.gps.server.IGpsService;
 import com.aidex.common.utils.StringUtils;
 import com.aidex.common.utils.dist.CalcDist;
+import com.aidex.framework.cache.ConfigUtils;
 import com.aidex.system.domain.SysNotice;
-import com.aidex.system.domain.SysShip;
 import com.aidex.system.domain.SysWharf;
 import com.aidex.system.service.SysNoticeService;
-import com.aidex.system.service.SysShipService;
 import com.aidex.system.service.SysWharfService;
+import org.apache.ibatis.javassist.expr.NewArray;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -53,8 +53,96 @@ public class AppService implements IAppService {
         return sysWharfService.findList(new SysWharf());
     }
 
-    public List<LocationEntity> findAllLocation(){
-        return iGpsService.getLocationBatch();
+    /*
+    * direction 方向 true正向 false反向
+    * */
+    public List<LocationVO> findAllLocation(Boolean direction){
+        // 全部船只信息
+        List<LocationEntity> locationEntities = iGpsService.getLocationBatch();
+        if(locationEntities.size() <= 0)
+            throw new SysException(8821,"暂无运行船只");
+
+        // 返回结果
+        List<LocationVO> locationList = new ArrayList<>();
+
+        Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
+
+        /* 正向运行 */
+        if(direction){
+            // 获取正向条件
+            String[] front = ConfigUtils.getConfigByKey("forward.direction").getConfigValue().split("-");
+            List<LocationEntity> frontList = locationEntities.stream().filter(local -> ((Double.valueOf(local.getDir()) >= Double.valueOf(front[0])) && (Double.valueOf(local.getDir()) <= Double.valueOf(front[1])))).collect(Collectors.toList());
+            for (LocationEntity locationEntity : frontList) {
+                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);
+            }
+
+        }else {
+            // 获取反向条件
+            String[] reverse = ConfigUtils.getConfigByKey("reverse.direction").getConfigValue().split("-");
+            List<LocationEntity> reverseList = locationEntities.stream().filter(local -> ((Double.valueOf(local.getDir()) >= Double.valueOf(reverse[0])) && (Double.valueOf(local.getDir()) <= Double.valueOf(reverse[1])))).collect(Collectors.toList());
+            for (LocationEntity locationEntity : reverseList) {
+                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;
+    }
+
+
+    public List<LocationVO> findAllLocationByNext(Boolean direction,String lat, String lon){
+        // 全部船只信息
+        List<LocationEntity> locationEntities = iGpsService.getLocationBatch();
+        if(locationEntities.size() <= 0)
+            throw new SysException(8821,"暂无运行船只");
+
+        // 返回结果
+        List<LocationVO> locationList = new ArrayList<>();
+        // 正反向计算数据
+        List<LocationEntity> calcList = new ArrayList<>();
+        // 停靠时间
+        Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
+
+        // 正反向计算条件
+        String[] conditions ;
+        /* 正向运行 */
+        if(direction){
+            // 获取正向条件
+            conditions = ConfigUtils.getConfigByKey("forward.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());
+        }else {
+            // 获取反向条件
+            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);
+            Integer stopTime = 0;
+            // 查询全部停止船只判断是否到站
+            if(Integer.valueOf(locationVO.getSpeed()) <= stopSpeed){
+                locationVO.setIsArrival(Boolean.TRUE);
+                // 如果处于停止状态则计算停留剩余时间
+                stopTime = CalcDist.calcStopTime(locationEntity.getUpdtime());
+            }
+
+            locationList.add(locationVO);
+        }
+        return locationList;
     }
 
     public List<SysWharfVO> findNearestStation(String lat, String lon){

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

@@ -1,5 +1,12 @@
 package com.aidex.common.utils.dist;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
 public class CalcDist {
 
     public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
@@ -21,4 +28,17 @@ public class CalcDist {
         double distance = earthRadius * c;
         return distance;
     }
+
+
+    public static Integer calcStopTime(String stopTime){
+        // 当前时间
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //  停船时间
+        LocalDateTime later = LocalDateTime.parse(stopTime,formatter);
+        // 计算两个时间之间的差值
+        Duration duration = Duration.between(now, later);
+        Long minutesBetween = duration.toMinutes();
+        return minutesBetween.intValue() < 0?0:minutesBetween.intValue();
+    }
 }

+ 5 - 2
aidex-ui/vue.config.js

@@ -27,7 +27,9 @@ const assetsCDN = {
     vue: 'Vue',
     'vue-router': 'VueRouter',
     vuex: 'Vuex',
-    axios: 'axios'
+    axios: 'axios',
+    qq: 'qq',
+    TMap: 'TMap'
   },
   css: [],
   // https://unpkg.com/browse/vue@2.6.10/
@@ -61,7 +63,8 @@ const vueConfig = {
     ],
     // if prod, add externals
     externals: isProd ? assetsCDN.externals
-    : {}
+    : { qq: 'qq',
+    TMap: 'TMap' }
   },
 
   chainWebpack: (config) => {