Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-devicemonitor
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit aba83272
authored
Aug 24, 2021
by
黄小葱
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
实现轨迹回放接口
1 parent
7dd8608e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
699 additions
and
6 deletions
src/main/java/cn/com/glsx/devicemonitor/modules/components/HdaoGpsComponent.java
src/main/java/cn/com/glsx/devicemonitor/modules/controller/MonitorController.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/BaseStationModel.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/BsInfoModel.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/JuhePoiModel.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/MobileBaseModel.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/StayPointModel.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackRequest.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackResponse.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/GpsBsLocationService.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/MonitorService.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/GpsBsLocationServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/utils/MapPointFix.java
src/main/java/cn/com/glsx/devicemonitor/modules/utils/PoiUtils.java
src/test/java/cn/com/glsx/test/gpsbs/MonitorTest.java
src/main/java/cn/com/glsx/devicemonitor/modules/components/HdaoGpsComponent.java
View file @
aba8327
This diff is collapsed.
Click to expand it.
src/main/java/cn/com/glsx/devicemonitor/modules/controller/MonitorController.java
View file @
aba8327
...
...
@@ -4,6 +4,9 @@ import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationBo;
import
cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum
;
import
cn.com.glsx.devicemonitor.common.BussinessExceptionEnum
;
import
cn.com.glsx.devicemonitor.common.ConstantsDevice
;
import
cn.com.glsx.devicemonitor.modules.model.StayPointModel
;
import
cn.com.glsx.devicemonitor.modules.model.TrackRequest
;
import
cn.com.glsx.devicemonitor.modules.model.TrackResponse
;
import
cn.com.glsx.devicemonitor.modules.service.MonitorService
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotBlank
;
import
java.util.List
;
/**
* @program: ne-shield-devicemonitor
...
...
@@ -36,16 +40,67 @@ public class MonitorController {
* @param sn
* @return
*/
@GetMapping
(
value
=
"/get
DeviceMonitorI
nfo"
)
public
R
getDeviceMonitorInfo
(
@NotBlank
(
message
=
"设备号不能为空"
)
@RequestParam
(
value
=
"sn"
)
String
sn
,
@NotBlank
(
message
=
"设备编码不能为空"
)
@RequestParam
(
value
=
"deviceCode"
)
String
deviceCode
,
Long
offlineTime
)
{
@GetMapping
(
value
=
"/get
devicemonitori
nfo"
)
public
R
getDeviceMonitorInfo
(
@NotBlank
(
message
=
"设备号不能为空"
)
@RequestParam
(
value
=
"sn"
)
String
sn
,
@NotBlank
(
message
=
"设备编码不能为空"
)
@RequestParam
(
value
=
"deviceCode"
)
String
deviceCode
)
{
if
(!
DeviceTypeRelationEnum
.
findByDeviceCode
(
deviceCode
).
equals
(
DeviceTypeRelationEnum
.
GPS
))
{
return
R
.
error
(
BussinessExceptionEnum
.
UNSUPORT_DEVICE
.
getCode
(),
BussinessExceptionEnum
.
UNSUPORT_DEVICE
.
getMessage
());
}
if
(
offlineTime
==
null
||
offlineTime
==
0
)
{
offlineTime
=
ConstantsDevice
.
OFFLINE_TIME_OTHER
;
}
//离线时间
Long
offlineTime
=
ConstantsDevice
.
OFFLINE_TIME_OTHER
;
DeviceLocationBo
deviceLocationBo
=
monitorService
.
getDeviceMonitorInfo
(
sn
,
offlineTime
,
DeviceTypeRelationEnum
.
findByDeviceCode
(
deviceCode
));
return
R
.
ok
().
data
(
deviceLocationBo
);
}
/**
* 获取某设备一定时间范围内的轨迹点数据,车辆监控轨迹回放
* @return
*/
@GetMapping
(
value
=
"/listtrackpoint"
)
public
R
listTrackPoint
(
TrackRequest
trackRequest
)
{
List
<
TrackResponse
>
responseList
=
null
;
try
{
responseList
=
monitorService
.
listTrackPoint
(
trackRequest
);
}
catch
(
Exception
e
)
{
log
.
info
(
"获取车辆轨迹数据异常:{}"
,
e
.
getMessage
());
return
R
.
error
(
e
.
getMessage
());
}
return
R
.
ok
().
data
(
responseList
);
}
/**
* 设备停留点查询
* @return
*/
@GetMapping
(
value
=
"/liststaypoint"
)
public
R
listStayPoint
(
TrackRequest
trackRequest
)
{
StayPointModel
stayPoint
=
new
StayPointModel
();
return
null
;
}
/**
* 导出轨迹数据
* @return
*/
@GetMapping
(
value
=
"/exporttrackpoint"
)
public
void
exportTrackPoint
(
TrackRequest
trackRequest
)
{
}
/**
* 导出停留点
* @return
*/
@GetMapping
(
value
=
"/exportstaypoint"
)
public
void
exportStayPoint
(
TrackRequest
trackRequest
)
{
}
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/BaseStationModel.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
import
java.util.List
;
/**
* @program: ne-shield-devicemonitor
* @description: 基站解析数据
* @author: huangxc
* @create: 2021-08-23 17
**/
@Data
public
class
BaseStationModel
{
/**
* 设备号
*/
private
String
sn
;
/**
* 移动国家代码(中国为460)
*/
private
String
mcc
;
/**
* 移动网络号码(中国移动为00, 中国联通为01)
*/
private
String
mnc
;
/**
* 位置区域码
*/
private
String
lac
;
/**
* 基站编号,是个16位的数据
*/
private
String
lcid
;
/**
* 定位时间
*/
private
String
time
;
/**
* 服务器时间
*/
private
String
storeTime
;
private
List
<
BsInfoModel
>
bsInfoList
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/BsInfoModel.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
/**
* @program: ne-shield-devicemonitor
* @description: ice中的基站基础数据
* @author: huangxc
* @create: 2021-08-23 17
**/
@Data
public
class
BsInfoModel
{
/**
* 位置区域码
*/
public
String
lac
;
/**
* 基站编号
*/
public
String
cellId
;
/**
* 信号
*/
public
int
signal
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/JuhePoiModel.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
/**
* @program: ne-shield-devicemonitor
* @description: 聚合POI
* @author: huangxc
* @create: 2021-08-24 10
**/
@Data
public
class
JuhePoiModel
{
@JsonProperty
(
value
=
"CELL"
)
private
String
CELL
;
@JsonProperty
(
value
=
"LAC"
)
private
String
LAC
;
@JsonProperty
(
value
=
"MCC"
)
private
String
MCC
;
@JsonProperty
(
value
=
"MNC"
)
private
String
MNC
;
@JsonProperty
(
value
=
"LNG"
)
private
String
LNG
;
@JsonProperty
(
value
=
"LAT"
)
private
String
LAT
;
@JsonProperty
(
value
=
"O_LNG"
)
private
String
O_LNG
;
@JsonProperty
(
value
=
"O_LAT"
)
private
String
O_LAT
;
@JsonProperty
(
value
=
"PRECISION"
)
private
String
PRECISION
;
@JsonProperty
(
value
=
"ADDRESS"
)
private
String
ADDRESS
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/MobileBaseModel.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
/**
* @program: ne-shield-devicemonitor
* @description: 基站解析结果
* @author: huangxc
* @create: 2021-08-23 18
**/
@Data
public
class
MobileBaseModel
{
private
String
lng
;
private
String
lat
;
private
String
elng
;
private
String
elat
;
private
String
blng
;
private
String
blat
;
private
String
address
;
private
int
precision
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/StayPointModel.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
/**
* @program: ne-shield-devicemonitor
* @description: 停留点
* @author: huangxc
* @create: 2021-08-24 14
**/
@Data
public
class
StayPointModel
{
/**
* 设备号
* */
private
String
sn
;
/**
* 开始停留时间
* */
private
String
begintime
;
/**
* 结束停留时间
* */
private
String
endtime
;
/**
* 停留时长
* */
private
String
duration
;
/**
* 定位方式 默认gps
* */
private
String
locationType
;
/**
* 停留纬度
* */
private
String
lat
;
/**
* 停留经度
* */
private
String
lng
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackRequest.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
/**
* @program: ne-shield-devicemonitor
* @description: 查询轨迹数据的请求model
* @author: huangxc
* @create: 2021-08-23 10
**/
@Data
@Validated
public
class
TrackRequest
{
/**
* 定位数据类型 0:gps; 1:基站
*/
@NotNull
(
message
=
"定位类型不能为null"
)
private
Integer
locationType
;
/**
* 设备号
*/
@NotEmpty
(
message
=
"sn不能为空"
)
private
String
sn
;
/**
* 开始时间
*/
@NotEmpty
(
message
=
"查询开始时间不能为空"
)
private
String
startTime
;
/**
* 结束时间
*/
@NotEmpty
(
message
=
"查询结束时间不能为空"
)
private
String
endTime
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackResponse.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
/**
* @program: ne-shield-devicemonitor
* @description: gps轨迹点响应数据
* @author: huangxc
* @create: 2021-08-23 14
**/
@Data
public
class
TrackResponse
{
/**
* 原始 经度
*/
private
String
lng
;
/**
* 原始 纬度
*/
private
String
lat
;
/**
* Google 经度
*/
private
String
elng
;
/**
* Google 纬度
*/
private
String
elat
;
/**
* Baidu 经度
*/
private
String
blng
;
/**
* Baidu 纬度
*/
private
String
blat
;
/**
* 经纬度时间
*/
private
String
dateTime
;
/**
* 地址信息
*/
private
String
address
;
/**
* 海拔
*/
private
String
alt
;
/**
* 方向
*/
private
String
dir
;
/**
* 存储时间
*/
private
String
storeTime
;
/**
* 速度
*/
private
String
speed
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/GpsBsLocationService.java
View file @
aba8327
...
...
@@ -40,4 +40,13 @@ public interface GpsBsLocationService {
* @return
*/
List
<
GpsLocation
>
getLastGpsBsHistoryBySn
(
String
sn
,
DeviceTypeRelationEnum
deviceTypeRelationEnum
,
String
startTime
,
String
endTime
);
/**
* 获取基站的轨迹数据点
* @param sn
* @param startTime
* @param endTime
* @return
*/
List
<
GpsLocation
>
getBaseStationPoint
(
String
sn
,
DeviceTypeRelationEnum
deviceTypeRelationEnum
,
String
startTime
,
String
endTime
);
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/MonitorService.java
View file @
aba8327
...
...
@@ -2,6 +2,10 @@ package cn.com.glsx.devicemonitor.modules.service;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationBo
;
import
cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum
;
import
cn.com.glsx.devicemonitor.modules.model.TrackRequest
;
import
cn.com.glsx.devicemonitor.modules.model.TrackResponse
;
import
java.util.List
;
public
interface
MonitorService
{
...
...
@@ -10,4 +14,12 @@ public interface MonitorService {
* @param sn
*/
DeviceLocationBo
getDeviceMonitorInfo
(
String
sn
,
long
offlineTime
,
DeviceTypeRelationEnum
deviceType
);
/**
* 获取某设备GPS轨迹点数据,车辆监控轨迹回放
* @param trackRequest
* @return
*/
List
<
TrackResponse
>
listTrackPoint
(
TrackRequest
trackRequest
);
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/GpsBsLocationServiceImpl.java
View file @
aba8327
...
...
@@ -8,9 +8,13 @@ import cn.com.glsx.devicemonitor.api.enums.GeoLocationEnum;
import
cn.com.glsx.devicemonitor.modules.components.HdaoGpsComponent
;
import
cn.com.glsx.devicemonitor.modules.convert.DataLocationConvert
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataGpsLocation
;
import
cn.com.glsx.devicemonitor.modules.model.BaseStationModel
;
import
cn.com.glsx.devicemonitor.modules.model.BsInfoModel
;
import
cn.com.glsx.devicemonitor.modules.model.MobileBaseModel
;
import
cn.com.glsx.devicemonitor.modules.service.GpsBsLocationService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -119,4 +123,33 @@ public class GpsBsLocationServiceImpl implements GpsBsLocationService {
}
return
DataLocationConvert
.
convertDataListToGpsLocation
(
dataGpsLocationList
);
}
@Override
public
List
<
GpsLocation
>
getBaseStationPoint
(
String
sn
,
DeviceTypeRelationEnum
deviceTypeRelationEnum
,
String
startTime
,
String
endTime
)
{
List
<
BaseStationModel
>
bsList
=
hdaoGpsComponent
.
getBaseStationPoint
(
sn
,
deviceTypeRelationEnum
.
getDataDeviceType
(),
startTime
,
endTime
);
if
(
CollectionUtils
.
isEmpty
(
bsList
))
{
return
new
ArrayList
<>();
}
List
<
GpsLocation
>
retList
=
new
ArrayList
<>();
//解析基站数据
for
(
BaseStationModel
bsModel
:
bsList
)
{
GpsLocation
location
=
new
GpsLocation
();
MobileBaseModel
mbModel
=
null
;
List
<
BsInfoModel
>
bsInfoList
=
bsModel
.
getBsInfoList
();
for
(
BsInfoModel
bsInfo
:
bsInfoList
)
{
mbModel
=
hdaoGpsComponent
.
analyzeBsData
(
bsInfo
.
getLac
(),
bsInfo
.
getCellId
(),
0
);
if
(
mbModel
!=
null
)
{
break
;
}
}
//整合数据
if
(
mbModel
!=
null
)
{
BeanUtils
.
copyProperties
(
mbModel
,
location
);
location
.
setStoreTime
(
bsModel
.
getStoreTime
());
location
.
setDateTime
(
bsModel
.
getTime
());
retList
.
add
(
location
);
}
}
return
retList
;
}
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
View file @
aba8327
...
...
@@ -9,20 +9,26 @@ import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import
cn.com.glsx.devicemonitor.api.dto.response.GpsLocation
;
import
cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataGpsLocation
;
import
cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper
;
import
cn.com.glsx.devicemonitor.modules.model.TrackRequest
;
import
cn.com.glsx.devicemonitor.modules.model.TrackResponse
;
import
cn.com.glsx.devicemonitor.modules.service.GpsBsLocationService
;
import
cn.com.glsx.devicemonitor.modules.service.MonitorService
;
import
cn.com.glsx.devicemonitor.modules.utils.DeviceUtils
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* @program: ne-shield-devicemonitor
...
...
@@ -51,7 +57,7 @@ public class MonitorServiceImpl implements MonitorService {
return
null
;
}
DeviceLocationBo
deviceLocationBo
=
new
DeviceLocationBo
();
//1.基站、gps数据
//1.基站、gps数据
、wifi数据
GpsBsData
gpsBsData
=
gpsBsLocationService
.
getLastGpsBsBySn
(
sn
,
deviceType
);
if
(
gpsBsData
!=
null
)
{
BeanUtils
.
copyProperties
(
gpsBsData
,
deviceLocationBo
);
...
...
@@ -77,6 +83,32 @@ public class MonitorServiceImpl implements MonitorService {
return
deviceLocationBo
;
}
@Override
public
List
<
TrackResponse
>
listTrackPoint
(
TrackRequest
trackRequest
)
{
List
<
TrackResponse
>
resList
=
new
ArrayList
<>();
String
sn
=
trackRequest
.
getSn
();
String
startTime
=
trackRequest
.
getStartTime
();
String
endTime
=
trackRequest
.
getEndTime
();
Integer
locationType
=
trackRequest
.
getLocationType
();
List
<
GpsLocation
>
gpsBsData
=
null
;
// 0:gps; 1:基站
if
(
locationType
==
0
)
{
gpsBsData
=
gpsBsLocationService
.
getLastGpsBsHistoryBySn
(
sn
,
DeviceTypeRelationEnum
.
findByDeviceCode
(
"gps"
),
startTime
,
endTime
);
}
else
{
gpsBsData
=
gpsBsLocationService
.
getBaseStationPoint
(
sn
,
DeviceTypeRelationEnum
.
findByDeviceCode
(
"gps"
),
startTime
,
endTime
);
}
if
(
CollectionUtils
.
isEmpty
(
gpsBsData
))
{
return
resList
;
}
for
(
GpsLocation
location
:
gpsBsData
)
{
TrackResponse
response
=
new
TrackResponse
();
BeanUtils
.
copyProperties
(
location
,
response
);
resList
.
add
(
response
);
}
return
resList
;
}
/**
* 设备离线状态
* @param deviceLocationBo
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/utils/MapPointFix.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
utils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
javax.annotation.PostConstruct
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @program: ne-shield-devicemonitor
* @description:
* @author: huangxc
* @create: 2021-08-24 10
**/
public
class
MapPointFix
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
MapPointFix
.
class
);
/**
* 点的偏差集合
*/
private
static
Map
<
String
,
BigDecimal
[]>
pDeviation
=
new
ConcurrentHashMap
<
String
,
BigDecimal
[]>();
/**
* 读取偏差表,计算偏差
*
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
@PostConstruct
public
void
init
()
throws
Exception
{
logger
.
info
(
"read point deviation begin......"
);
long
beginTime
=
System
.
currentTimeMillis
();
List
<
String
>
points
=
FileUtils
.
readLines
(
FileUtils
.
toFile
(
this
.
getClass
().
getClassLoader
().
getResource
(
"table.txt"
)));
int
x
=
719
;
int
y
=
99
;
// x轴标准点值
BigDecimal
pointXStandard
=
null
;
// y轴标准点值
BigDecimal
pointYStandard
=
null
;
// 每个点与标准点的偏差
BigDecimal
[]
pd
=
null
;
for
(
String
pointStr
:
points
)
{
// 每个pointXY有两个点
String
[]
pointXY
=
StringUtils
.
trim
(
pointStr
).
split
(
"\\s+"
);
x
+=
1
;
if
(
"7200000"
.
equals
(
pointXY
[
0
]))
{
x
=
720
;
y
+=
1
;
pointYStandard
=
new
BigDecimal
(
y
).
divide
(
new
BigDecimal
(
10
));
}
// 计算第一个点的偏差
pointXStandard
=
new
BigDecimal
(
x
).
divide
(
new
BigDecimal
(
10
));
pd
=
new
BigDecimal
[]
{
new
BigDecimal
(
pointXY
[
0
]).
divide
(
new
BigDecimal
(
100000
)).
subtract
(
pointXStandard
),
new
BigDecimal
(
pointXY
[
1
]).
divide
(
new
BigDecimal
(
100000
)).
subtract
(
pointYStandard
)
};
pDeviation
.
put
(
String
.
valueOf
(
x
)
+
y
,
pd
);
// 计算第二个点的偏差
x
+=
1
;
pointXStandard
=
new
BigDecimal
(
x
).
divide
(
new
BigDecimal
(
10
));
pd
=
new
BigDecimal
[]
{
new
BigDecimal
(
pointXY
[
2
]).
divide
(
new
BigDecimal
(
100000
)).
subtract
(
pointXStandard
),
new
BigDecimal
(
pointXY
[
3
]).
divide
(
new
BigDecimal
(
100000
)).
subtract
(
pointYStandard
)
};
pDeviation
.
put
(
String
.
valueOf
(
x
)
+
y
,
pd
);
}
logger
.
info
(
"read point deviation end...... "
+
(
System
.
currentTimeMillis
()
-
beginTime
)
+
"ms"
);
}
/**
* 获取修正后的点
*
* @param longitude
* @param latitude
* @param toGMap
* @return
*/
public
static
String
[]
getFixedPoint
(
String
longitude
,
String
latitude
,
boolean
toGMap
)
{
longitude
=
StringUtils
.
trim
(
longitude
);
latitude
=
StringUtils
.
trim
(
latitude
);
int
i
=
longitude
.
indexOf
(
"."
);
int
j
=
latitude
.
indexOf
(
"."
);
// 点的偏差集合中的key
String
pDeviationKey
=
longitude
.
substring
(
0
,
i
)
+
longitude
.
substring
(
i
+
1
,
i
+
2
)
+
latitude
.
substring
(
0
,
j
)
+
latitude
.
substring
(
j
+
1
,
j
+
2
);
BigDecimal
[]
pd
=
pDeviation
.
get
(
pDeviationKey
);
String
[]
point
=
new
String
[]
{
longitude
,
latitude
};
if
(
pd
!=
null
)
{
if
(
toGMap
)
{
point
=
new
String
[]
{
new
BigDecimal
(
longitude
).
add
(
pd
[
0
]).
toString
(),
new
BigDecimal
(
latitude
).
add
(
pd
[
1
]).
toString
()
};
}
else
{
point
=
new
String
[]
{
new
BigDecimal
(
longitude
).
subtract
(
pd
[
0
]).
toString
(),
new
BigDecimal
(
latitude
).
subtract
(
pd
[
1
]).
toString
()
};
}
}
return
point
;
}
/**
* 获取修正后的点
* @param longitude
* @param latitude
* @return
*/
public
static
String
getFixedPoint
(
String
longitude
,
String
latitude
)
{
longitude
=
StringUtils
.
trim
(
longitude
);
latitude
=
StringUtils
.
trim
(
latitude
);
int
i
=
longitude
.
indexOf
(
"."
);
int
j
=
latitude
.
indexOf
(
"."
);
// 点的偏差集合中的key
String
pDeviationKey
=
longitude
.
substring
(
0
,
i
)
+
longitude
.
substring
(
i
+
1
,
i
+
2
)
+
latitude
.
substring
(
0
,
j
)
+
latitude
.
substring
(
j
+
1
,
j
+
2
);
BigDecimal
[]
pd
=
pDeviation
.
get
(
pDeviationKey
);
String
point
=
null
;
if
(
pd
!=
null
)
{
point
=
new
BigDecimal
(
longitude
).
add
(
pd
[
0
])
+
","
+
new
BigDecimal
(
latitude
).
add
(
pd
[
1
]);
}
return
point
;
}
}
src/main/java/cn/com/glsx/devicemonitor/modules/utils/PoiUtils.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @program: ne-shield-devicemonitor
* @description: Poi工具类
* @author: huangxc
* @create: 2021-08-24 10
**/
@Slf4j
public
class
PoiUtils
{
private
static
double
x_pi
=
3.14159265358979324
*
3000.0
/
180.0
;
public
static
String
bd_encrypt
(
double
gg_lat
,
double
gg_lon
)
{
double
x
=
gg_lon
,
y
=
gg_lat
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
+
0.00002
*
Math
.
sin
(
y
*
x_pi
);
double
theta
=
Math
.
atan2
(
y
,
x
)
+
0.000003
*
Math
.
cos
(
x
*
x_pi
);
double
bd_lon
=
z
*
Math
.
cos
(
theta
)
+
0.0065
;
double
bd_lat
=
z
*
Math
.
sin
(
theta
)
+
0.006
;
return
bd_lat
+
","
+
bd_lon
;
}
public
static
String
bd_decrypt
(
double
bd_lat
,
double
bd_lon
)
{
double
x
=
bd_lon
-
0.0065
,
y
=
bd_lat
-
0.006
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
-
0.00002
*
Math
.
sin
(
y
*
x_pi
);
double
theta
=
Math
.
atan2
(
y
,
x
)
-
0.000003
*
Math
.
cos
(
x
*
x_pi
);
double
gg_lon
=
z
*
Math
.
cos
(
theta
);
double
gg_lat
=
z
*
Math
.
sin
(
theta
);
return
gg_lat
+
","
+
gg_lon
;
}
public
static
String
convert
(
Double
lat
,
Double
lon
,
int
type
)
{
String
ret
=
""
;
try
{
switch
(
type
)
{
case
0
:
ret
=
bd_encrypt
(
lat
,
lon
);
break
;
case
1
:
String
[]
pointFixed
=
MapPointFix
.
getFixedPoint
(
lon
.
toString
(),
lat
.
toString
(),
false
);
ret
=
pointFixed
[
1
]
+
","
+
pointFixed
[
0
];
break
;
case
2
:
ret
=
bd_decrypt
(
lat
,
lon
);
break
;
case
3
:
String
res
=
bd_decrypt
(
lat
,
lon
);
log
.
info
(
"google poi is :"
+
res
);
String
arr_p
[]
=
res
.
split
(
","
);
String
[]
pointFixed1
=
MapPointFix
.
getFixedPoint
(
arr_p
[
1
],
arr_p
[
0
],
false
);
ret
=
pointFixed1
[
1
]
+
","
+
pointFixed1
[
0
];
break
;
case
4
:
String
[]
pointFixed2
=
MapPointFix
.
getFixedPoint
(
lon
.
toString
(),
lat
.
toString
(),
true
);
ret
=
pointFixed2
[
1
]
+
","
+
pointFixed2
[
0
];
break
;
case
5
:
String
[]
pointFixed3
=
MapPointFix
.
getFixedPoint
(
lon
.
toString
(),
lat
.
toString
(),
true
);
ret
=
bd_encrypt
(
Double
.
valueOf
(
pointFixed3
[
1
]),
Double
.
valueOf
(
pointFixed3
[
0
]));
log
.
info
(
"baidu poi is :"
+
ret
);
break
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"error:"
,
e
);
}
return
ret
;
}
private
final
static
double
PI
=
3.14159265358979323
;
// 圆周率
private
final
static
double
R
=
6371229
;
// 地球的半径
public
static
double
getDistance
(
double
longt1
,
double
lat1
,
double
longt2
,
double
lat2
)
{
double
x
,
y
,
distance
;
x
=
(
longt2
-
longt1
)
*
PI
*
R
*
Math
.
cos
(((
lat1
+
lat2
)
/
2
)
*
PI
/
180
)
/
180
;
y
=
(
lat2
-
lat1
)
*
PI
*
R
/
180
;
distance
=
Math
.
hypot
(
x
,
y
);
return
distance
;
}
}
src/test/java/cn/com/glsx/test/gpsbs/MonitorTest.java
0 → 100644
View file @
aba8327
package
cn
.
com
.
glsx
.
test
.
gpsbs
;
import
cn.hutool.http.HttpUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @program: ne-shield-devicemonitor
* @description: Monitor测试
* @author: huangxc
* @create: 2021-08-24 15
**/
public
class
MonitorTest
{
private
static
String
localUrl
=
"http://localhost:8080/ne-shield-devicemonitor"
;
private
static
String
serverUrl
=
localUrl
;
public
static
void
main
(
String
[]
args
)
{
listTrackPointTest
();
}
public
static
void
listTrackPointTest
()
{
String
url
=
serverUrl
+
"/monitor/listtrackpoint"
;
String
sn
=
"1610816002"
;
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"sn"
,
sn
);
paramMap
.
put
(
"locationType"
,
"1"
);
paramMap
.
put
(
"startTime"
,
"2021-08-21 15:29:00"
);
paramMap
.
put
(
"endTime"
,
"2021-08-24 15:29:00"
);
String
res
=
HttpUtil
.
get
(
url
,
paramMap
,
30000
);
System
.
out
.
println
(
res
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment