Compare commits
2 Commits
53ba41ba2a
...
5407da4c93
| Author | SHA256 | Date | |
|---|---|---|---|
| 5407da4c93 | |||
| d11da6ae13 |
@ -73,6 +73,12 @@
|
|||||||
<version>2025.1.0</version>
|
<version>2025.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.locationtech.jts</groupId>
|
||||||
|
<artifactId>jts-core</artifactId>
|
||||||
|
<version>1.18.2</version> <!-- 请使用最新版本 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package com.ebike.feign.model.dto;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -21,6 +21,6 @@ public class FeignEbikeDto implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 定位
|
* 定位
|
||||||
*/
|
*/
|
||||||
private PGpoint location;
|
private Point location;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -101,6 +101,6 @@ public class FeignEbikeUserBikeInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 车辆运营区
|
* 车辆运营区
|
||||||
*/
|
*/
|
||||||
private PGpolygon regionPolygon;
|
private Polygon regionPolygon;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -33,7 +33,7 @@ public class EbikeLockVo implements Serializable {
|
|||||||
|
|
||||||
|
|
||||||
@NotNull(message = "车辆当前位置不能为空")
|
@NotNull(message = "车辆当前位置不能为空")
|
||||||
private PGpoint point;
|
private Point point;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -29,7 +29,7 @@ public class FeignEbikeBikeRadiusVo implements Serializable {
|
|||||||
* 用户所在坐标
|
* 用户所在坐标
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "用户所在坐标不能为空")
|
@NotNull(message = "用户所在坐标不能为空")
|
||||||
private PGpoint point;
|
private Point point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户所在坐标
|
* 用户所在坐标
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -47,7 +47,7 @@ public class FeignEbikeRegionVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 区域
|
* 区域
|
||||||
*/
|
*/
|
||||||
private PGpolygon regionPolygon;
|
private Polygon regionPolygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 站点数量
|
* 站点数量
|
||||||
|
|||||||
@ -19,7 +19,10 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||||||
import com.mybatisflex.core.update.UpdateChain;
|
import com.mybatisflex.core.update.UpdateChain;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
|
import org.locationtech.jts.geom.GeometryFactory;
|
||||||
|
import org.locationtech.jts.geom.Point;
|
||||||
|
import org.locationtech.jts.geom.PrecisionModel;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -189,8 +192,10 @@ public class EbikeBikeInfoController {
|
|||||||
log.warn("中控未绑定车辆或不存在,SN={}", ecuSn);
|
log.warn("中控未绑定车辆或不存在,SN={}", ecuSn);
|
||||||
return JsonResult.failed();
|
return JsonResult.failed();
|
||||||
}else {
|
}else {
|
||||||
|
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
|
||||||
|
Point location = geometryFactory.createPoint(new Coordinate(longitude, latitude));
|
||||||
UpdateChain.of(EbikeBikeInfo.class)
|
UpdateChain.of(EbikeBikeInfo.class)
|
||||||
.set(EBIKE_BIKE_INFO.LOCATION,new PGpoint(longitude,latitude))
|
.set(EBIKE_BIKE_INFO.LOCATION,location)
|
||||||
.where(EBIKE_BIKE_INFO.BIKE_INFO_ID.eq(bikeInfo.getBikeInfoId()))
|
.where(EBIKE_BIKE_INFO.BIKE_INFO_ID.eq(bikeInfo.getBikeInfoId()))
|
||||||
.update();
|
.update();
|
||||||
log.info("更新车辆位置成功,SN={}", ecuSn);
|
log.info("更新车辆位置成功,SN={}", ecuSn);
|
||||||
|
|||||||
@ -20,7 +20,10 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||||||
import com.mybatisflex.core.update.UpdateChain;
|
import com.mybatisflex.core.update.UpdateChain;
|
||||||
import com.mybatisflex.core.util.StringUtil;
|
import com.mybatisflex.core.util.StringUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
|
import org.locationtech.jts.geom.GeometryFactory;
|
||||||
|
import org.locationtech.jts.geom.Point;
|
||||||
|
import org.locationtech.jts.geom.PrecisionModel;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -262,8 +265,9 @@ public class EbikeRegionController {
|
|||||||
@GetMapping("getRegionByLocation")
|
@GetMapping("getRegionByLocation")
|
||||||
public JsonResult<?> getRegionByLocation(@RequestParam("lng") double lng,
|
public JsonResult<?> getRegionByLocation(@RequestParam("lng") double lng,
|
||||||
@RequestParam("lat") double lat) {
|
@RequestParam("lat") double lat) {
|
||||||
PGpoint point = new PGpoint(lng, lat);
|
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
|
||||||
EbikeRegion region = ebikeRegionService.getRegionByLocation(point);
|
Point location = geometryFactory.createPoint(new Coordinate(lng, lat));
|
||||||
|
EbikeRegion region = ebikeRegionService.getRegionByLocation(location);
|
||||||
return JsonResult.success(region);
|
return JsonResult.success(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import com.cdzy.operations.model.dto.EbikeDto;
|
|||||||
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.apache.ibatis.annotations.Param;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public interface EbikeBikeInfoMapper extends BaseMapper<EbikeBikeInfo> {
|
|||||||
* @param polygon 多边形
|
* @param polygon 多边形
|
||||||
* @return 列表
|
* @return 列表
|
||||||
*/
|
*/
|
||||||
List<EbikeBikeInfo> selectPolygonGeometry(@Param("polygon") PGpolygon polygon);
|
List<EbikeBikeInfo> selectPolygonGeometry(@Param("polygon") Polygon polygon);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询半径范围内的车辆(带距离排序)
|
* 查询半径范围内的车辆(带距离排序)
|
||||||
@ -30,7 +30,7 @@ public interface EbikeBikeInfoMapper extends BaseMapper<EbikeBikeInfo> {
|
|||||||
* @param radiusMeters 半径距离(米)
|
* @param radiusMeters 半径距离(米)
|
||||||
* @return 按距离排序的车辆列表
|
* @return 按距离排序的车辆列表
|
||||||
*/
|
*/
|
||||||
List<EbikeDto> selectRadiusGeometryWithOrder(@Param("centerPoint") PGpoint centerPoint,
|
List<EbikeDto> selectRadiusGeometryWithOrder(@Param("centerPoint") Point centerPoint,
|
||||||
@Param("radius") double radiusMeters);
|
@Param("radius") double radiusMeters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.cdzy.operations.mapper;
|
|||||||
|
|
||||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public interface EbikeRegionMapper extends BaseMapper<EbikeRegion> {
|
|||||||
* @param point 用户当前位置
|
* @param point 用户当前位置
|
||||||
* @return 列表
|
* @return 列表
|
||||||
*/
|
*/
|
||||||
List<EbikeRegion> findAllRegionsOrderByDistance(PGpoint point);
|
List<EbikeRegion> findAllRegionsOrderByDistance(Point point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据当前位置查询当前运营区
|
* 根据当前位置查询当前运营区
|
||||||
@ -36,5 +36,5 @@ public interface EbikeRegionMapper extends BaseMapper<EbikeRegion> {
|
|||||||
* @param point 用户当前位置
|
* @param point 用户当前位置
|
||||||
* @return 运营区信息
|
* @return 运营区信息
|
||||||
*/
|
*/
|
||||||
EbikeRegion findCurrentRegion(PGpoint point);
|
EbikeRegion findCurrentRegion(Point point);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -41,10 +40,10 @@ public class EbikeReportRecord implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 上报位置
|
* 上报位置
|
||||||
*/
|
*/
|
||||||
@Column(typeHandler = PGpointTypeHandler.class)
|
@Column(typeHandler = PointTypeHandler.class)
|
||||||
@JsonSerialize(using = PGpointSerializer.class)
|
@JsonSerialize(using = PointSerializer.class)
|
||||||
@JsonDeserialize(using = PGpointDeserializer.class)
|
@JsonDeserialize(using = PointDeserializer.class)
|
||||||
private PGpoint location;
|
private Point location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上报原因
|
* 上报原因
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -61,7 +61,7 @@ public class EbikeSite implements Serializable {
|
|||||||
@Column(typeHandler = PolygonTypeHandler.class)
|
@Column(typeHandler = PolygonTypeHandler.class)
|
||||||
@JsonSerialize(using = PolygonSerializer.class)
|
@JsonSerialize(using = PolygonSerializer.class)
|
||||||
@JsonDeserialize(using = PolygonDeserializer.class)
|
@JsonDeserialize(using = PolygonDeserializer.class)
|
||||||
private PGpolygon sitePolygon;
|
private Polygon sitePolygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 站点类型:1-普通站点(停车) 2-禁停区 3-仓库区
|
* 站点类型:1-普通站点(停车) 2-禁停区 3-仓库区
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.postgresql.geometric.PGpolygon;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class EbikeSiteVo implements Serializable {
|
|||||||
* 站点区域
|
* 站点区域
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "站点区域不能为空")
|
@NotNull(message = "站点区域不能为空")
|
||||||
private PGpolygon sitePolygon;
|
private Polygon sitePolygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 站点类型:1-普通站点(停车) 2-禁停区 3-仓库区
|
* 站点类型:1-普通站点(停车) 2-禁停区 3-仓库区
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import com.cdzy.operations.model.vo.EbikeOperationConfigVo;
|
|||||||
import com.cdzy.operations.model.vo.EbikeRegionVo;
|
import com.cdzy.operations.model.vo.EbikeRegionVo;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
import com.cdzy.operations.model.entity.EbikeRegion;
|
import com.cdzy.operations.model.entity.EbikeRegion;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运营区域表 服务层。
|
* 运营区域表 服务层。
|
||||||
@ -41,8 +41,8 @@ public interface EbikeRegionService extends IService<EbikeRegion> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据当前位置查询当前运营区信息
|
* 根据当前位置查询当前运营区信息
|
||||||
* @param pGpoint 当前位置
|
* @param point 当前位置
|
||||||
* @return 运营区信息
|
* @return 运营区信息
|
||||||
*/
|
*/
|
||||||
EbikeRegion getRegionByLocation(PGpoint pGpoint);
|
EbikeRegion getRegionByLocation(Point point);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import com.mybatisflex.core.update.UpdateChain;
|
|||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -703,7 +703,7 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<EbikeRegion> regionList(OrderRegionVo orderRegionVo) {
|
public List<EbikeRegion> regionList(OrderRegionVo orderRegionVo) {
|
||||||
PGpoint point = orderRegionVo.getPoint();
|
Point point = orderRegionVo.getPoint();
|
||||||
if (point != null) {
|
if (point != null) {
|
||||||
return regionMapper.findAllRegionsOrderByDistance(point);
|
return regionMapper.findAllRegionsOrderByDistance(point);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import com.cdzy.operations.service.EbikeRegionService;
|
|||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.postgresql.geometric.PGpoint;
|
import org.locationtech.jts.geom.Point;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class EbikeRegionServiceImpl extends ServiceImpl<EbikeRegionMapper, Ebike
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EbikeRegion getRegionByLocation(PGpoint pGpoint) {
|
public EbikeRegion getRegionByLocation(Point point) {
|
||||||
return this.mapper.findCurrentRegion(pGpoint);
|
return this.mapper.findCurrentRegion(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<resultMap id="EbikeDtoMap" type="com.cdzy.operations.model.dto.EbikeDto">
|
<resultMap id="EbikeDtoMap" type="com.cdzy.operations.model.dto.EbikeDto">
|
||||||
<result column="bike_code" property="bikeCode"/>
|
<result column="bike_code" property="bikeCode"/>
|
||||||
<result column="location" property="location" typeHandler="com.cdzy.operations.handler.PGpointTypeHandler"/>
|
<result column="location" property="location" typeHandler="com.cdzy.operations.handler.PointTypeHandler"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectPolygonGeometry" resultType="com.cdzy.operations.model.entity.EbikeBikeInfo">
|
<select id="selectPolygonGeometry" resultType="com.cdzy.operations.model.entity.EbikeBikeInfo">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user