| | |
| | | import com.xiaopeng.api.dto.operation.PointMapQuery; |
| | | import com.xiaopeng.api.dto.order.HistoryEndPointsDto; |
| | | import com.xiaopeng.api.dto.order.HistoryStartPointsDto; |
| | | import com.xiaopeng.api.model.operation.XpBanner; |
| | | import com.xiaopeng.api.model.operation.XpPoint; |
| | | import com.xiaopeng.api.model.operation.XpSystemSetting; |
| | | import com.xiaopeng.api.model.operation.*; |
| | | import com.xiaopeng.api.query.operation.PointListQuery; |
| | | import com.xiaopeng.api.query.operation.PointPageListListQuery; |
| | | import com.xiaopeng.api.vo.order.XpHistoryEndPointsVo; |
| | |
| | | import com.xiaopeng.operation.mapper.XpPointMapper; |
| | | import com.xiaopeng.operation.mapper.XpSystemSettingMapper; |
| | | import com.xiaopeng.operation.query.PointByNameQuery; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceAreaService; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceService; |
| | | import com.xiaopeng.operation.service.XpPointService; |
| | | import com.xiaopeng.operation.utils.TimeRangeChecker; |
| | | import com.xiaopeng.operation.utils.holiday.HolidayUtil; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | @Resource |
| | | private HolidayUtil holidayUtil; |
| | | |
| | | @Resource |
| | | private IXpElectronicFenceAreaService xpElectronicFenceAreaService; |
| | | |
| | | @Resource |
| | | private IXpElectronicFenceService xpElectronicFenceService; |
| | | |
| | | |
| | | @Override |
| | | public NearestVo nearest(NearestDto dto) { |
| | |
| | | NearestVo nearestVo = new NearestVo(); |
| | | List<NearestNextVo> nearestNextVos = new ArrayList<>(); |
| | | LocalTime now = LocalTime.now(); |
| | | List<Long> areaIds = list.stream().map(XpPoint::getElectronicAreaId).collect(Collectors.toList()); |
| | | List<XpElectronicFenceArea> xpElectronicFenceAreas = xpElectronicFenceAreaService.listByIds(areaIds); |
| | | List<Long> fenceIds = xpElectronicFenceAreas.stream().map(XpElectronicFenceArea::getElectronicId).collect(Collectors.toList()); |
| | | List<XpElectronicFence> xpElectronicFences = xpElectronicFenceService.listByIds(fenceIds); |
| | | |
| | | |
| | | //判断当前点位是否在运营时间范围内 |
| | | for (XpPoint xpPoint : list) { |
| | | Integer operationType = xpPoint.getOperationType(); |
| | | if(1 == operationType){ |
| | | //与运营区同步 |
| | | XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreas.stream().filter(s -> s.getId().equals(xpPoint.getElectronicAreaId())).findFirst().orElse(null); |
| | | if(null == xpElectronicFenceArea){ |
| | | continue; |
| | | } |
| | | XpElectronicFence xpElectronicFence = xpElectronicFences.stream().filter(s -> s.getId().equals(xpElectronicFenceArea.getElectronicId())).findFirst().orElse(null); |
| | | if(null == xpElectronicFence){ |
| | | continue; |
| | | } |
| | | //失效类型 1=永不失效 2=定时失效 |
| | | Integer failureType = xpElectronicFence.getFailureType(); |
| | | //永不失效,但是还未到开始时间 |
| | | if(1 == failureType && LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ |
| | | continue; |
| | | } |
| | | //定时失效,但是当前时间不在时间范围内 |
| | | if(LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime())){ |
| | | continue; |
| | | } |
| | | }else{ |
| | | //自定义时间段 |
| | | // 判断是否在时间段内 |
| | | boolean intime = getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); |
| | | if (!intime) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // 计算距离 小于的站点 |
| | | double v = FastDistanceCalculator.distanceFast(dto.getLatitude(), dto.getLongitude(), xpPoint.getPointLat(), xpPoint.getPointLon()); |
| | | if (v < orderDistance) { |