Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qianhe-slsy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xuwenhao
qianhe-slsy
Commits
e42fd409
Commit
e42fd409
authored
Mar 14, 2024
by
yuanchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20240314
parent
a0685375
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
10 deletions
+59
-10
qianhe-admin/pom.xml
+3
-2
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterGoodsCart.java
+2
-0
qianhe-admin/src/main/java/com/qianhe/system/service/impl/WaterStationServiceImpl.java
+18
-6
qianhe-admin/src/main/java/com/qianhe/system/utils/AMapUtils.java
+3
-2
qianhe-admin/src/main/java/com/qianhe/system/utils/PositionUtil.java
+33
-0
No files found.
qianhe-admin/pom.xml
View file @
e42fd409
...
...
@@ -115,10 +115,11 @@
</dependency>
<!--微信支付-->
<!-- 微信支付V3 目前新版本-->
<dependency>
<groupId>
com.github.wechatpay-apiv3
</groupId>
<artifactId>
wechatpay-
java
</artifactId>
<version>
0.
2.12
</version>
<artifactId>
wechatpay-
apache-httpclient
</artifactId>
<version>
0.
4.9
</version>
</dependency>
<dependency>
...
...
qianhe-admin/src/main/java/com/qianhe/system/domain/WaterGoodsCart.java
View file @
e42fd409
...
...
@@ -59,6 +59,8 @@ public class WaterGoodsCart {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
private
String
openId
;
/** 封面图集合 */
private
List
<
WaterGoodsImg
>
coverImgs
;
...
...
qianhe-admin/src/main/java/com/qianhe/system/service/impl/WaterStationServiceImpl.java
View file @
e42fd409
...
...
@@ -252,7 +252,15 @@ public class WaterStationServiceImpl implements IWaterStationService
@Override
public
WaterStationVo
getRecentlyStation1
(
String
address
,
String
address1
)
{
double
[]
doubles
=
AMapUtils
.
addressToGPS
(
address
);
double
[]
doubles
;
if
(
address1
.
contains
(
address
)){
doubles
=
AMapUtils
.
addressToGPS
(
address
);
}
else
{
doubles
=
AMapUtils
.
addressToGPS
(
address
+
address1
);
}
double
lon
=
doubles
[
0
];
double
lat
=
doubles
[
1
];
//查询所有站点信息
...
...
@@ -260,11 +268,9 @@ public class WaterStationServiceImpl implements IWaterStationService
List
<
WaterStationVo
>
waterStationVoList
=
new
ArrayList
<>();
//循环站点,计算符合距离的站点
for
(
WaterStation
waterStation
:
waterStations
)
{
//判断用户和站点之前的距离是否在站点管辖范围之内
boolean
inCircle
=
PositionUtil
.
isInCircle
(
lon
,
lat
,
waterStation
.
getStationLonTen
(),
waterStation
.
getStationLatTen
(),
"5000"
);
//计算距离
double
distance
=
PositionUtil
.
getDistance
(
lon
,
lat
,
waterStation
.
getStationLonTen
(),
waterStation
.
getStationLatTen
(),
Ellipsoid
.
WGS84
);
if
(
inCircle
){
double
distance
=
PositionUtil
.
getDistance
1
(
lon
,
lat
,
waterStation
.
getStationLonTen
(),
waterStation
.
getStationLatTen
()
);
if
(
distance
<
5000
){
WaterStationVo
waterStationVo
=
new
WaterStationVo
();
BeanUtils
.
copyProperties
(
waterStation
,
waterStationVo
);
waterStationVo
.
setDistance
(
distance
);
...
...
@@ -273,7 +279,13 @@ public class WaterStationServiceImpl implements IWaterStationService
}
//根据距离排序,选出最近的站点
List
<
WaterStationVo
>
collect
=
waterStationVoList
.
stream
().
sorted
(
Comparator
.
comparing
(
WaterStationVo:
:
getDistance
)).
collect
(
Collectors
.
toList
());
return
collect
.
get
(
0
);
WaterStationVo
stationVo
=
new
WaterStationVo
();
if
(
collect
.
size
()>
0
){
stationVo
=
collect
.
get
(
0
);
}
return
stationVo
;
}
/**
...
...
qianhe-admin/src/main/java/com/qianhe/system/utils/AMapUtils.java
View file @
e42fd409
...
...
@@ -62,11 +62,11 @@ public class AMapUtils {
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
/*
public static void main(String[] args) {
String address = "广州市总统大酒店";
double[] doubles = addressToGPS(address);
System.out.println(address+"、经度: "+doubles[0]);
System.out.println(address+"、纬度: "+doubles[1]);
}
}
*/
}
\ No newline at end of file
qianhe-admin/src/main/java/com/qianhe/system/utils/PositionUtil.java
View file @
e42fd409
...
...
@@ -13,6 +13,39 @@ import org.springframework.stereotype.Component;
@Component
public
class
PositionUtil
{
/**
* 赤道半径
*/
private
static
final
double
EQUATOR_RADIUS
=
6378137
;
/**
* 方法一:(反余弦计算方式)
*
* @param longitude1 第一个点的经度
* @param latitude1 第一个点的纬度
* @param longitude2 第二个点的经度
* @param latitude2 第二个点的纬度
* @return 返回距离,单位m
*/
public
static
double
getDistance1
(
double
longitude1
,
double
latitude1
,
double
longitude2
,
double
latitude2
)
{
// 纬度
double
lat1
=
Math
.
toRadians
(
latitude1
);
double
lat2
=
Math
.
toRadians
(
latitude2
);
// 经度
double
lon1
=
Math
.
toRadians
(
longitude1
);
double
lon2
=
Math
.
toRadians
(
longitude2
);
// 纬度之差
double
a
=
lat1
-
lat2
;
// 经度之差
double
b
=
lon1
-
lon2
;
// 计算两点距离的公式
double
s
=
2
*
Math
.
asin
(
Math
.
sqrt
(
Math
.
pow
(
Math
.
sin
(
a
/
2
),
2
)
+
Math
.
cos
(
lat1
)
*
Math
.
cos
(
lat2
)
*
Math
.
pow
(
Math
.
sin
(
b
/
2
),
2
)));
// 弧长乘赤道半径, 返回单位: 米
s
=
s
*
EQUATOR_RADIUS
;
return
s
;
}
/**
* 方法四:(利用第三方jar包计算)
* 计算两个经纬度之间的距离
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment