Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-performance
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
姜武杰
clx-performance
Commits
7549c033
提交
7549c033
authored
8月 13, 2024
作者:
jiangwujie
浏览文件
操作
浏览文件
下载
差异文件
feature(电子围栏): 增加计算距离接口
上级
afec83d4
8ef285db
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
11 行删除
+35
-11
TempTraceController.java
.../clx/performance/controller/temp/TempTraceController.java
+13
-7
GdService.java
...src/main/java/com/clx/performance/utils/gd/GdService.java
+22
-4
没有找到文件。
performance-web/src/main/java/com/clx/performance/controller/temp/TempTraceController.java
浏览文件 @
7549c033
package
com
.
clx
.
performance
.
controller
.
temp
;
import
com.clx.performance.dto.gd.GdRouteDTO
;
import
com.clx.performance.param.mq.trace.TruckTraceSyncMqParam
;
import
com.clx.performance.esplus.model.TruckLatestPosESPlus
;
import
com.clx.performance.param.mq.trace.TruckTraceSyncMqParam
;
import
com.clx.performance.param.temp.DriverTraceAddParam
;
import
com.clx.performance.param.temp.TruckTraceAddParam
;
import
com.clx.performance.service.trace.TruckTraceMqHandlerService
;
...
...
@@ -20,12 +20,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.math.BigDecimal
;
import
java.util.List
;
...
...
@@ -138,4 +132,16 @@ public class TempTraceController {
}
@ApiOperation
(
value
=
"获取车辆最新位置信息"
,
notes
=
"<br>By:姜武杰"
)
@GetMapping
(
"/calDistance"
)
public
Result
<
Integer
>
getTruckLatestPos
(
@RequestParam
(
"l1"
)
@NotNull
(
message
=
"当前经度不能为空"
)
BigDecimal
l1
,
@RequestParam
(
"l2"
)
@NotNull
(
message
=
"当前纬度不能为空"
)
BigDecimal
l2
,
@RequestParam
(
"l3"
)
@NotNull
(
message
=
"货源经度不能为空"
)
BigDecimal
l3
,
@RequestParam
(
"l4"
)
@NotNull
(
message
=
"货源纬度不能为空"
)
BigDecimal
l4
)
{
return
Result
.
ok
(
gdService
.
getShortestRouteDistance
(
l1
,
l2
,
l3
,
l4
));
}
}
performance-web/src/main/java/com/clx/performance/utils/gd/GdService.java
浏览文件 @
7549c033
...
...
@@ -9,14 +9,12 @@ import com.msl.common.enums.ResultCodeEnum;
import
com.msl.common.exception.ServiceSystemException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.dromara.easyes.common.utils.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
/**
* @Author: aiqingguo
...
...
@@ -47,6 +45,26 @@ public class GdService {
return
getRoute
(
gaodeKey
,
originLongitude
,
originLatitude
,
destinationLongitude
,
destinationLatitude
);
}
/**
* 获取最短距离路径
* @param originLongitude
* @param originLatitude
* @param destinationLongitude
* @param destinationLatitude
* @return
*/
public
Integer
getShortestRouteDistance
(
BigDecimal
originLongitude
,
BigDecimal
originLatitude
,
BigDecimal
destinationLongitude
,
BigDecimal
destinationLatitude
)
{
List
<
GdRouteDTO
>
routeList
=
getRoute
(
gaodeKey
,
originLongitude
,
originLatitude
,
destinationLongitude
,
destinationLatitude
);
if
(
CollectionUtils
.
isNotEmpty
(
routeList
))
{
Optional
<
GdRouteDTO
>
minRoute
=
routeList
.
stream
()
.
min
((
r1
,
r2
)
->
Double
.
compare
(
r1
.
getDistance
(),
r2
.
getDistance
()));
return
minRoute
.
map
(
GdRouteDTO:
:
getDistance
).
orElse
(
null
);
}
return
null
;
}
public
static
List
<
GdRouteDTO
>
getRoute
(
String
key
,
BigDecimal
originLongitude
,
BigDecimal
originLatitude
,
BigDecimal
destinationLongitude
,
BigDecimal
destinationLatitude
)
{
//log.info("高德线路规划开始");
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论