| | |
| | | package com.xiaopeng.map.service.serviceimpl; |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.xiaopeng.map.mapper.XpElectronicFenceAreaMapper; |
| | | import com.xiaopeng.map.mapper.XpElectronicFenceMapper; |
| | | import com.xiaopeng.map.service.XpElectronicFenceAreaService; |
| | | import com.xiaopeng.map.service.XpPointService; |
| | | import com.xiaopeng.map.utils.AmapWalkingRouteUtil; |
| | | import com.xiaopeng.map.utils.ElectricFenceUtil; |
| | | import com.xiaopeng.map.utils.GDMapGeocodingUtil; |
| | |
| | | import com.xiaopeng.map.utils.holiday.HolidayUtil; |
| | | import com.xiaopeng.map.vo.IsInOperationAreaVo; |
| | | import com.xiaopeng.map.vo.WalkTimeVo; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | @Autowired |
| | | private XpPointService xpPointService; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<XpElectronicFenceVo> citiesList(String cityCode) { |
| | | public List<XpElectronicFenceVo> citiesList(String cityCode,String uid) { |
| | | List<XpGeoFencingPolygon> xpGeoFencingPolygons = mongoTemplate.find(new Query(Criteria.where("cityCode").is(cityCode)), XpGeoFencingPolygon.class); |
| | | if(xpGeoFencingPolygons.isEmpty()){ |
| | | return new ArrayList<>(); |
| | |
| | | if(xpElectronicFences==null){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Set<Long> collectStationIds = null; |
| | | if(null!= uid){ |
| | | collectStationIds = xpPointService.getCollectStationIds(uid); |
| | | } |
| | | |
| | | for (XpGeoFencingPolygon polygon : xpGeoFencingPolygons) { |
| | | XpElectronicFence xpElectronicFence = xpElectronicFences.getData().stream().filter(e -> e.getId().toString().equals(polygon.getFenceId())).findFirst().orElse(null); |
| | | if(xpElectronicFence==null){ |
| | |
| | | // 设置id(使用siteId作为id) |
| | | vo.setFenceId(polygon.getFenceId()); |
| | | vo.setAreaId(polygon.getAreaId()); |
| | | vo.setStationId(polygon.getStationId()); |
| | | vo.setStationIsCollect(false); |
| | | if(StrUtil.isNotBlank(polygon.getStationId())){ |
| | | if (CollUtil.isNotEmpty(collectStationIds) && collectStationIds.contains(Long.valueOf(polygon.getStationId()) ) ) { |
| | | vo.setStationIsCollect(true); |
| | | } |
| | | } |
| | | // 设置围栏名称 |
| | | vo.setName(polygon.getName()); |
| | | // 转换GeoJsonPolygon为List<XpPointsVo> |
| | |
| | | pointsVoList.add(pointsVo); |
| | | } |
| | | } |
| | | vo.setType(polygon.getStationId() == null ? 1 : 2); |
| | | vo.setPoints(pointsVoList); |
| | | vo.setRule(operationStrategy); |
| | | result.add(vo); |