Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-performance
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
姜武杰
clx-performance
Commits
429e8e37
提交
429e8e37
authored
9月 21, 2023
作者:
liuhaiquan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
cecfafd5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
122 行增加
和
24 行删除
+122
-24
PageVicinityTruckListParam.java
.../clx/performance/param/pc/PageVicinityTruckListParam.java
+27
-0
TruckController.java
...va/com/clx/performance/controller/pc/TruckController.java
+9
-0
TruckService.java
...c/main/java/com/clx/performance/service/TruckService.java
+3
-0
TruckServiceImpl.java
...va/com/clx/performance/service/impl/TruckServiceImpl.java
+81
-22
RedisGeoUntil.java
...rc/main/java/com/clx/performance/utils/RedisGeoUntil.java
+2
-2
没有找到文件。
performance-api/src/main/java/com/clx/performance/param/pc/PageVicinityTruckListParam.java
0 → 100644
浏览文件 @
429e8e37
package
com
.
clx
.
performance
.
param
.
pc
;
import
com.msl.common.base.PageParam
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.validation.constraints.NotNull
;
/**
* @ClassName PageTruckListParam
* @Description
* @Author kavin
* @Date 2023/9/19 16:04
* @Version 1.0
*/
@Getter
@Setter
public
class
PageVicinityTruckListParam
extends
PageParam
{
@NotNull
(
message
=
"订单编号不能为空"
)
@ApiModelProperty
(
value
=
"订单编号"
,
example
=
"PT2023091600001"
)
private
String
orderNo
;
}
performance-web/src/main/java/com/clx/performance/controller/pc/TruckController.java
浏览文件 @
429e8e37
package
com
.
clx
.
performance
.
controller
.
pc
;
import
com.clx.performance.param.pc.PageTruckListParam
;
import
com.clx.performance.param.pc.PageVicinityTruckListParam
;
import
com.clx.performance.service.TruckService
;
import
com.clx.performance.vo.pc.PageTruckListVO
;
import
com.msl.common.base.PageData
;
...
...
@@ -47,5 +48,13 @@ public class TruckController {
@ApiOperation
(
value
=
"获取附近的车辆"
,
notes
=
"<br>By:刘海泉"
)
@PostMapping
(
"/getVicinityTruckList"
)
public
Result
<
PageData
<
PageTruckListVO
>>
getVicinityTruckList
(
@RequestBody
@Validated
PageVicinityTruckListParam
param
)
{
PageData
<
PageTruckListVO
>
page
=
truckService
.
getVicinityTruckList
(
param
);
return
Result
.
ok
(
page
);
}
}
performance-web/src/main/java/com/clx/performance/service/TruckService.java
浏览文件 @
429e8e37
package
com
.
clx
.
performance
.
service
;
import
com.clx.performance.param.pc.PageTruckListParam
;
import
com.clx.performance.param.pc.PageVicinityTruckListParam
;
import
com.clx.performance.vo.pc.PageTruckListVO
;
import
com.msl.common.base.PageData
;
...
...
@@ -17,4 +18,6 @@ public interface TruckService {
void
test
();
void
handExecTruckTrace
();
PageData
<
PageTruckListVO
>
getVicinityTruckList
(
PageVicinityTruckListParam
param
);
}
performance-web/src/main/java/com/clx/performance/service/impl/TruckServiceImpl.java
浏览文件 @
429e8e37
...
...
@@ -7,6 +7,7 @@ import com.clx.performance.constant.RedisConstants;
import
com.clx.performance.dto.zjxl.TruckTraceDTO
;
import
com.clx.performance.job.TruckTraceJob
;
import
com.clx.performance.param.pc.PageTruckListParam
;
import
com.clx.performance.param.pc.PageVicinityTruckListParam
;
import
com.clx.performance.service.TruckService
;
import
com.clx.performance.utils.RedisGeoUntil
;
import
com.clx.performance.vo.pc.PageTruckListVO
;
...
...
@@ -58,16 +59,16 @@ public class TruckServiceImpl implements TruckService {
@Autowired
TruckTraceJob
truckTraceJob
;
/**
* @Author kavin
* @Description
获取车辆列表
* @Param [
param
]
* @Description
geo 获取附近车辆
* @Param []
* @return
**/
@Override
public
PageData
<
PageTruckListVO
>
pageTruckList
(
PageTruckListParam
param
)
{
private
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
vicinityTruckList
(
String
orderNo
,
Integer
maxShowTruckNum
,
double
MaxDistance
){
//获取发货地经纬度
FeignOrderVO
orderInfoFeign
=
orderFeign
.
getOrderInfoFeign
(
param
.
getOrderNo
()
);
FeignOrderVO
orderInfoFeign
=
orderFeign
.
getOrderInfoFeign
(
orderNo
);
BigDecimal
sendLatitude
=
orderInfoFeign
.
getSendLatitude
();
//精度
BigDecimal
sendLongitude
=
orderInfoFeign
.
getSendLongitude
();
//维度
if
(
Objects
.
isNull
(
sendLatitude
)
||
Objects
.
isNull
(
sendLongitude
)){
...
...
@@ -79,22 +80,8 @@ public class TruckServiceImpl implements TruckService {
if
(
MapUtils
.
isEmpty
(
map
)){
log
.
warn
(
"缓存中车辆位置信息列表为空,缓存key:{}"
,
RedisConstants
.
ZJXL_TRUCK_TRACE_LIST
);
return
new
PageData
<>();
}
//查询平台所有车辆的出车状态信息
Result
<
List
<
TruckUseStatusVO
>>
result
=
userClxFeign
.
getPlatformTruckStatus
();
log
.
info
(
"通过clx-user服务获取平台认证成功车辆出车状态列表,返回结果:{}"
,
result
);
if
(!
Objects
.
equals
(
result
.
getCode
(),
ResultCodeEnum
.
SUCCESS
.
getCode
())){
throw
new
ServiceSystemException
(
ResultEnum
.
DATA_NOT_FIND
,
"查询车辆出车状态信息失败"
);
return
null
;
}
Map
<
String
,
Integer
>
truckStatusMap
=
new
HashMap
<>();
result
.
getData
().
stream
().
forEach
(
item
->{
truckStatusMap
.
put
(
item
.
getTruckNo
(),
item
.
getTruckOrderStatus
());
});
String
redisGeoKey
=
RedisConstants
.
TRUCK_LOCATION_KEY
+
UUID
.
randomUUID
();
...
...
@@ -109,10 +96,28 @@ public class TruckServiceImpl implements TruckService {
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
sortResult
=
redisGeoUntil
.
getRedisGeoMaxIntegerKm
(
redisGeoKey
,
sendLongitude
.
doubleValue
(),
sendLatitude
.
doubleValue
(),
param
.
getNeedTruckNum
()
*
4
);
maxShowTruckNum
,
MaxDistance
);
//清除缓存geo数据
redisGeoUntil
.
deleteAllRedisGeo
(
redisGeoKey
);
return
sortResult
;
}
/**
* @Author kavin
* @Description 获取车辆列表
* @Param [param]
* @return
**/
@Override
public
PageData
<
PageTruckListVO
>
pageTruckList
(
PageTruckListParam
param
)
{
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
sortResult
=
this
.
vicinityTruckList
(
param
.
getOrderNo
(),
param
.
getNeedTruckNum
()*
4
,
Integer
.
MAX_VALUE
);
if
(
Objects
.
isNull
(
sortResult
)){
return
new
PageData
<>();
}
Map
<
String
,
Integer
>
truckStatusMap
=
this
.
getTruckStatusMap
();
List
<
GeoResult
<
RedisGeoCommands
.
GeoLocation
<
String
>>>
content
=
sortResult
.
getContent
();
List
<
PageTruckListVO
>
filterList
=
new
ArrayList
<>();
//车辆距离发货地由近及远的车辆列表信息
...
...
@@ -148,6 +153,58 @@ public class TruckServiceImpl implements TruckService {
return
pageData
;
}
/**
* @Author kavin
* @Description 查询附近10公里内的车辆
* @Param [param]
* @return
**/
@Override
public
PageData
<
PageTruckListVO
>
getVicinityTruckList
(
PageVicinityTruckListParam
param
)
{
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
sortResult
=
this
.
vicinityTruckList
(
param
.
getOrderNo
(),
100000
,
10
);
Map
<
String
,
Integer
>
truckStatusMap
=
this
.
getTruckStatusMap
();
List
<
PageTruckListVO
>
list
=
new
ArrayList
<>();
List
<
GeoResult
<
RedisGeoCommands
.
GeoLocation
<
String
>>>
content
=
sortResult
.
getContent
();
for
(
GeoResult
<
RedisGeoCommands
.
GeoLocation
<
String
>>
item
:
content
){
String
truckLevel
=
"A"
;
String
truckNo
=
item
.
getContent
().
getName
();
double
maxDistance
=
item
.
getDistance
().
getValue
();
PageTruckListVO
vo
=
PageTruckListVO
.
builder
().
truckNo
(
truckNo
).
truckLevel
(
truckLevel
).
maxDistance
(
maxDistance
).
truckUserStatus
(
truckStatusMap
.
get
(
truckNo
)).
build
();
list
.
add
(
vo
);
}
//分页
PageData
<
PageTruckListVO
>
pageData
=
new
PageData
();
pageData
.
setPages
(
param
.
getPage
());
pageData
.
setTotal
(
list
.
size
());
pageData
.
setRecords
(
pageBySubList
(
list
,
param
.
getPageSize
(),
param
.
getPage
()));
return
pageData
;
}
/**
* @Author kavin
* @Description 获取平台用车状态信息
* @Param []
* @return
**/
private
Map
<
String
,
Integer
>
getTruckStatusMap
(){
//查询平台所有车辆的出车状态信息
Result
<
List
<
TruckUseStatusVO
>>
result
=
userClxFeign
.
getPlatformTruckStatus
();
log
.
info
(
"通过clx-user服务获取平台认证成功车辆出车状态列表,返回结果:{}"
,
result
);
if
(!
Objects
.
equals
(
result
.
getCode
(),
ResultCodeEnum
.
SUCCESS
.
getCode
())){
throw
new
ServiceSystemException
(
ResultEnum
.
DATA_NOT_FIND
,
"查询车辆出车状态信息失败"
);
}
Map
<
String
,
Integer
>
truckStatusMap
=
new
HashMap
<>();
result
.
getData
().
stream
().
forEach
(
item
->{
truckStatusMap
.
put
(
item
.
getTruckNo
(),
item
.
getTruckOrderStatus
());
});
return
truckStatusMap
;
}
@Override
public
void
test
()
{
...
...
@@ -161,7 +218,7 @@ public class TruckServiceImpl implements TruckService {
redisGeoUntil
.
updateRedisGeo
(
"station"
,
116.562108
,
39.787602
,
"花荄站点"
);
redisGeoUntil
.
updateRedisGeo
(
"station"
,
116.334255
,
40.027400
,
"三台县站点"
);
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
sortResult
=
redisGeoUntil
.
getRedisGeoMaxIntegerKm
(
"station"
,
116.334212
,
39.992813
,
5
);
"station"
,
116.334212
,
39.992813
,
5
,
Integer
.
MAX_VALUE
);
List
<
GeoResult
<
RedisGeoCommands
.
GeoLocation
<
String
>>>
content
=
sortResult
.
getContent
();
...
...
@@ -176,6 +233,8 @@ public class TruckServiceImpl implements TruckService {
GeoResult [content: RedisGeoCommands.GeoLocation(name=花荄站点, point=Point [x=116.562106, y=39.787603]), distance: 29.987 KILOMETERS, ]*/
}
}
/**
* @Author kavin
* @Description 手动执行获取车辆定位信息
...
...
performance-web/src/main/java/com/clx/performance/utils/RedisGeoUntil.java
浏览文件 @
429e8e37
...
...
@@ -111,11 +111,11 @@ public class RedisGeoUntil {
/**
* //中心点设置 某个经纬度算距离
*/
public
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
getRedisGeoMaxIntegerKm
(
String
redisKey
,
Double
longitudeX
,
Double
latitudeY
,
Integer
limit
)
{
public
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
getRedisGeoMaxIntegerKm
(
String
redisKey
,
Double
longitudeX
,
Double
latitudeY
,
Integer
limit
,
double
maxDistance
)
{
//longitude,latitude
//中心点设置 某个经纬度算距离
Point
pointCenter
=
new
Point
(
longitudeX
,
latitudeY
);
Distance
distanceCenter
=
new
Distance
(
Integer
.
MAX_VALUE
,
RedisGeoCommands
.
DistanceUnit
.
KILOMETERS
);
Distance
distanceCenter
=
new
Distance
(
maxDistance
,
RedisGeoCommands
.
DistanceUnit
.
KILOMETERS
);
Circle
circleCenter
=
new
Circle
(
pointCenter
,
distanceCenter
);
RedisGeoCommands
.
GeoRadiusCommandArgs
argsCircle
=
RedisGeoCommands
.
GeoRadiusCommandArgs
.
newGeoRadiusArgs
().
includeDistance
().
includeCoordinates
().
sortAscending
().
limit
(
limit
);
GeoResults
<
RedisGeoCommands
.
GeoLocation
<
String
>>
resultsDis
=
redisTemplate
.
opsForGeo
().
radius
(
redisKey
,
circleCenter
,
argsCircle
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论