| | |
| | | import com.xiaopeng.map.service.XpElectronicFenceAreaService; |
| | | import com.xiaopeng.map.utils.AmapWalkingRouteUtil; |
| | | import com.xiaopeng.map.utils.ElectricFenceUtil; |
| | | import com.xiaopeng.map.utils.GDMapGeocodingUtil; |
| | | import com.xiaopeng.map.utils.GaodeMapService; |
| | | import com.xiaopeng.map.utils.holiday.HolidayUtil; |
| | | import com.xiaopeng.map.vo.IsInOperationAreaVo; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Resource |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | continue; |
| | | } |
| | | // 是否运营时间内 |
| | | if(xpElectronicFence.getFailureType() == 2){ |
| | | Boolean inOperationTime = isInOperationTime(operationStrategy); |
| | | if(!inOperationTime){ |
| | | continue; |
| | | } |
| | | |
| | | }else{ |
| | | //永不失效,需要判断开始时间是否到达 |
| | | if(LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | XpElectronicFenceVo vo = new XpElectronicFenceVo(); |
| | | // 设置id(使用siteId作为id) |
| | |
| | | public IsInOperationAreaVo isInOperationArea(LonLatDto dto) { |
| | | |
| | | IsInOperationAreaVo vo = new IsInOperationAreaVo(); |
| | | List<XpGeoFencingPolygon> xpGeoFencingPolygons = xpGeoFencingPolygonService.findAll(); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(dto.getLongitude().toString(), dto.getLatitude().toString()); |
| | | if(null == geocode){ |
| | | throw new RuntimeException("经纬度转换城市code失败"); |
| | | } |
| | | String cityCode = geocode.get("cityCode"); |
| | | List<XpGeoFencingPolygon> xpGeoFencingPolygons = mongoTemplate.find(new Query(Criteria.where("cityCode").is(cityCode)), XpGeoFencingPolygon.class); |
| | | for (XpGeoFencingPolygon polygon : xpGeoFencingPolygons) { |
| | | if (polygon.getPoints() != null && polygon.getPoints().getCoordinates() != null) { |
| | | // GeoJsonPolygon的coordinates是一个二维数组,第一个元素是外部环 |
| | |
| | | String fenceId = polygon.getFenceId(); |
| | | R<XpElectronicFence> xpElectronicFence = xpElectronicFenceClient.selectById(fenceId); |
| | | if(xpElectronicFence!=null && null != xpElectronicFence.getData()){ |
| | | String operationStrategy = xpElectronicFence.getData().getOperationStrategy(); |
| | | Boolean inOperationTime = isInOperationTime(operationStrategy); |
| | | XpElectronicFence electronicFence = xpElectronicFence.getData(); |
| | | String operationStrategy = electronicFence.getOperationStrategy(); |
| | | Boolean inOperationTime = true; |
| | | if(electronicFence.getFailureType() == 2){ |
| | | inOperationTime = isInOperationTime(operationStrategy); |
| | | } |
| | | if(inOperationTime){ |
| | | vo.setStatus("inside"); |
| | | vo.setElectronicAreaId(Long.valueOf(polygon.getAreaId())); |