From f8c322050a8325164d18d8be779d269683d1ccd20a43c6a13aca5e65e8ded009 Mon Sep 17 00:00:00 2001 From: attiya <2413103649@qq.com> Date: Wed, 22 Oct 2025 16:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E7=9A=84=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E5=86=85=E6=9F=A5=E8=AF=A2=EF=BC=88=E6=9C=AA=E5=81=9A=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cdzy/operations/service/EbikeBikeInfoService.java | 10 ++++++++++ .../service/impl/EbikeBikeInfoServiceImpl.java | 11 +++++++++++ .../operations/EbikeOperationsApplicationTests.java | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeBikeInfoService.java b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeBikeInfoService.java index edc132c..a5d8ba4 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeBikeInfoService.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/EbikeBikeInfoService.java @@ -3,6 +3,9 @@ package com.cdzy.operations.service; import com.cdzy.operations.model.vo.EbikeBikeBindVo; import com.mybatisflex.core.service.IService; import com.cdzy.operations.model.entity.EbikeBikeInfo; +import org.postgresql.geometric.PGpolygon; + +import java.util.List; /** * 服务层。 @@ -17,4 +20,11 @@ public interface EbikeBikeInfoService extends IService { * @param bindVo 绑定信息 */ void bind(EbikeBikeBindVo bindVo); + + /** + * 查询区域内车辆 + * @param polygon 区域 + * @return 列表 + */ + List list(PGpolygon polygon); } diff --git a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeBikeInfoServiceImpl.java b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeBikeInfoServiceImpl.java index 4997c42..b099b57 100644 --- a/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeBikeInfoServiceImpl.java +++ b/ebike-operations/src/main/java/com/cdzy/operations/service/impl/EbikeBikeInfoServiceImpl.java @@ -16,6 +16,7 @@ import com.cdzy.operations.service.EbikeInventoryService; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; import jakarta.annotation.Resource; +import org.postgresql.geometric.PGpolygon; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -146,4 +147,14 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl list(PGpolygon polygon) { + QueryWrapper query = QueryWrapper.create() + .select(EBIKE_BIKE_INFO.ALL_COLUMNS) + .from(EBIKE_BIKE_INFO) + .where("ST_Within(location::geometry, ?::geometry)",polygon); + return this.mapper.selectListByQuery(query); + } + } diff --git a/ebike-operations/src/test/java/com/cdzy/operations/EbikeOperationsApplicationTests.java b/ebike-operations/src/test/java/com/cdzy/operations/EbikeOperationsApplicationTests.java index 19c0722..18c7905 100644 --- a/ebike-operations/src/test/java/com/cdzy/operations/EbikeOperationsApplicationTests.java +++ b/ebike-operations/src/test/java/com/cdzy/operations/EbikeOperationsApplicationTests.java @@ -1,7 +1,7 @@ package com.cdzy.operations; -import com.cdzy.operations.mapper.EbikeBikeInfoMapper; import com.cdzy.operations.model.entity.EbikeBikeInfo; +import com.cdzy.operations.service.EbikeBikeInfoService; import org.junit.jupiter.api.Test; import org.postgresql.geometric.PGpoint; import org.postgresql.geometric.PGpolygon; @@ -14,7 +14,7 @@ import java.util.List; class EbikeOperationsApplicationTests { @Autowired - private EbikeBikeInfoMapper bikeInfoMapper; + private EbikeBikeInfoService bikeInfoService; @Test void contextLoads(){ @@ -24,7 +24,7 @@ class EbikeOperationsApplicationTests { PGpoint gpoint4 = new PGpoint(103.943116,30.6327); PGpoint[] points = new PGpoint[]{gpoint1,gpoint2,gpoint3,gpoint4}; PGpolygon pgpolygon = new PGpolygon(points); - List bikeInfos = bikeInfoMapper.selectPolygonGeometry(pgpolygon); + List bikeInfos = bikeInfoService.list(pgpolygon); for (EbikeBikeInfo bikeInfo : bikeInfos) { System.out.println(bikeInfo); }