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