区域基础管理功能、车辆的区域内查询(未做状态筛选
This commit is contained in:
parent
154dd2fd8e
commit
e17825be22
@ -2,6 +2,10 @@ package com.cdzy.operations.mapper;
|
|||||||
|
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.postgresql.geometric.PGpolygon;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 映射层。
|
* 映射层。
|
||||||
@ -11,4 +15,11 @@ import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
|||||||
*/
|
*/
|
||||||
public interface EbikeBikeInfoMapper extends BaseMapper<EbikeBikeInfo> {
|
public interface EbikeBikeInfoMapper extends BaseMapper<EbikeBikeInfo> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询多边形范围内的车辆
|
||||||
|
* @param polygon 多边形
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
List<EbikeBikeInfo> selectPolygonGeometry(@Param("polygon") PGpolygon polygon);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.cdzy.operations.service.impl;
|
package com.cdzy.operations.service.impl;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.cdzy.common.ex.EbikeException;
|
||||||
import com.cdzy.operations.enums.RegionStatus;
|
import com.cdzy.operations.enums.RegionStatus;
|
||||||
import com.cdzy.operations.mapper.EbikeRegionMapper;
|
import com.cdzy.operations.mapper.EbikeRegionMapper;
|
||||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||||
@ -39,6 +40,9 @@ public class EbikeRegionServiceImpl extends ServiceImpl<EbikeRegionMapper, Ebike
|
|||||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
.where(EBIKE_REGION.REGION_ID.eq(ebikeRegion.getRegionId()));
|
.where(EBIKE_REGION.REGION_ID.eq(ebikeRegion.getRegionId()));
|
||||||
EbikeRegion region = this.mapper.selectOneByQuery(queryWrapper);
|
EbikeRegion region = this.mapper.selectOneByQuery(queryWrapper);
|
||||||
|
if (region.getStatus() == RegionStatus.OPERATION) {
|
||||||
|
throw new EbikeException("该区域运营中不能修改");
|
||||||
|
}
|
||||||
region.setOperatorId(ebikeRegion.getOperatorId());
|
region.setOperatorId(ebikeRegion.getOperatorId());
|
||||||
region.setRegionPolygon(ebikeRegion.getRegionPolygon());
|
region.setRegionPolygon(ebikeRegion.getRegionPolygon());
|
||||||
region.setRegionName(ebikeRegion.getRegionName());
|
region.setRegionName(ebikeRegion.getRegionName());
|
||||||
|
|||||||
@ -58,9 +58,9 @@ spring:
|
|||||||
max-idle: 10
|
max-idle: 10
|
||||||
# 连接池中的最小空闲连接
|
# 连接池中的最小空闲连接
|
||||||
min-idle: 0
|
min-idle: 0
|
||||||
|
|
||||||
mybatis-flex:
|
mybatis-flex:
|
||||||
mapper-locations: classpath:mapper/*.xml
|
mapper-locations: classpath:mapper/*.xml
|
||||||
|
type-handlers-package: com.cdzy.operations.handler
|
||||||
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
||||||
sa-token:
|
sa-token:
|
||||||
# token 名称(同时也是 cookie 名称)
|
# token 名称(同时也是 cookie 名称)
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cdzy.operations.mapper.EbikeBikeInfoMapper">
|
||||||
|
|
||||||
|
<select id="selectPolygonGeometry" resultType="com.cdzy.operations.model.entity.EbikeBikeInfo">
|
||||||
|
SELECT *
|
||||||
|
FROM ebike_bike_info
|
||||||
|
WHERE ST_Within(location::geometry, #{polygon}::geometry)
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -1,18 +1,20 @@
|
|||||||
package com.cdzy.operations;
|
package com.cdzy.operations;
|
||||||
|
|
||||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
import com.cdzy.operations.mapper.EbikeBikeInfoMapper;
|
||||||
import com.cdzy.operations.service.EbikeRegionService;
|
import com.cdzy.operations.model.entity.EbikeBikeInfo;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.postgresql.geometric.PGpoint;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.postgresql.geometric.PGpolygon;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class EbikeOperationsApplicationTests {
|
class EbikeOperationsApplicationTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EbikeRegionService regionService;
|
private EbikeBikeInfoMapper bikeInfoMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads(){
|
void contextLoads(){
|
||||||
@ -22,14 +24,10 @@ class EbikeOperationsApplicationTests {
|
|||||||
PGpoint gpoint4 = new PGpoint(103.943116,30.6327);
|
PGpoint gpoint4 = new PGpoint(103.943116,30.6327);
|
||||||
PGpoint[] points = new PGpoint[]{gpoint1,gpoint2,gpoint3,gpoint4};
|
PGpoint[] points = new PGpoint[]{gpoint1,gpoint2,gpoint3,gpoint4};
|
||||||
PGpolygon pgpolygon = new PGpolygon(points);
|
PGpolygon pgpolygon = new PGpolygon(points);
|
||||||
EbikeRegion ebikeRegion = EbikeRegion.builder()
|
List<EbikeBikeInfo> bikeInfos = bikeInfoMapper.selectPolygonGeometry(pgpolygon);
|
||||||
.operatorId(311460622768435200L)
|
for (EbikeBikeInfo bikeInfo : bikeInfos) {
|
||||||
.regionName("测试区域")
|
System.out.println(bikeInfo);
|
||||||
.regionPolygon(pgpolygon)
|
}
|
||||||
.createdBy(320131029184712704L)
|
|
||||||
.status(0)
|
|
||||||
.build();
|
|
||||||
regionService.save(ebikeRegion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user