|
@@ -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){
|