Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
map-parent
Commits
97b651db
Commit
97b651db
authored
May 31, 2021
by
YANGYANG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户实时轨迹 提交
parent
a45b1c62
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
1 deletions
+140
-1
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/LocationData.java
+46
-0
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/controller/ZdryApiController.java
+13
-1
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
+3
-0
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
+78
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/LocationData.java
0 → 100644
View file @
97b651db
package
com
.
founder
.
commonutils
.
ZdryApiEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
@Data
@ApiModel
(
value
=
"locationData对象"
,
description
=
"locationData对象"
)
public
class
LocationData
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
" 设备"
)
private
String
device
;
@ApiModelProperty
(
value
=
"记录时间"
)
private
String
created_at
;
@ApiModelProperty
(
value
=
"发生时间"
)
private
String
time_begin
;
@ApiModelProperty
(
value
=
"0:Gps定位; 1:基站定位"
)
private
String
type
;
@ApiModelProperty
(
value
=
"城市"
)
private
String
city
;
@ApiModelProperty
(
value
=
"地址"
)
private
String
address
;
@ApiModelProperty
(
value
=
"x经度"
)
private
String
x
;
@ApiModelProperty
(
value
=
"y纬度"
)
private
String
y
;
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/controller/ZdryApiController.java
View file @
97b651db
...
@@ -5,6 +5,7 @@ import com.founder.commonutils.publicEntity.MapRestResult;
...
@@ -5,6 +5,7 @@ import com.founder.commonutils.publicEntity.MapRestResult;
import
com.founder.zdryapi.service.ZdryApiService
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -37,7 +38,8 @@ public class ZdryApiController {
...
@@ -37,7 +38,8 @@ public class ZdryApiController {
@ApiOperation
(
value
=
"查看指定设备接口"
)
@ApiOperation
(
value
=
"查看指定设备接口"
)
@PostMapping
(
value
=
"/getDevice"
)
@PostMapping
(
value
=
"/getDevice"
)
public
Device
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
public
Device
getDevice
(
@ApiParam
(
name
=
"deviceId"
,
value
=
"设备IMEI"
,
required
=
true
)
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
long
startTime
=
new
Date
().
getTime
();
long
startTime
=
new
Date
().
getTime
();
Device
result
=
zdryApiService
.
getDevice
(
deviceId
);
Device
result
=
zdryApiService
.
getDevice
(
deviceId
);
long
endTime
=
new
Date
().
getTime
();
long
endTime
=
new
Date
().
getTime
();
...
@@ -51,5 +53,15 @@ public class ZdryApiController {
...
@@ -51,5 +53,15 @@ public class ZdryApiController {
public
String
updateDevice
(
@RequestBody
Device
deviceParam
)
{
public
String
updateDevice
(
@RequestBody
Device
deviceParam
)
{
return
zdryApiService
.
updateDevice
(
deviceParam
);
return
zdryApiService
.
updateDevice
(
deviceParam
);
}
}
@ApiOperation
(
value
=
"查看设备定位数据"
)
@PostMapping
(
value
=
"/locationdata"
)
public
MapRestResult
locationdata
(
@ApiParam
(
name
=
"deviceId"
,
value
=
"设备IMEI"
,
required
=
true
)
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
,
@ApiParam
(
name
=
"time_begin"
,
value
=
"YYYYMMDD,查询指定日期的数据"
)
@RequestParam
(
required
=
false
)
String
time_begin
)
{
return
zdryApiService
.
locationdata
(
deviceId
,
time_begin
);
}
}
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
View file @
97b651db
...
@@ -18,4 +18,7 @@ public interface ZdryApiService {
...
@@ -18,4 +18,7 @@ public interface ZdryApiService {
Device
getDevice
(
String
deviceId
);
Device
getDevice
(
String
deviceId
);
String
updateDevice
(
Device
deviceParam
);
String
updateDevice
(
Device
deviceParam
);
MapRestResult
locationdata
(
String
deviceId
,
String
time_begin
);
}
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
View file @
97b651db
package
com
.
founder
.
zdryapi
.
service
.
impl
;
package
com
.
founder
.
zdryapi
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.founder.commonutils.ZdryApiEntity.Device
;
import
com.founder.commonutils.ZdryApiEntity.Device
;
import
com.founder.commonutils.ZdryApiEntity.LocationData
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -13,6 +16,11 @@ import org.springframework.http.MediaType;
...
@@ -13,6 +16,11 @@ import org.springframework.http.MediaType;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/*
/*
*
*
* <p>
* <p>
...
@@ -44,6 +52,8 @@ public class ZdryApiServiceImpl implements ZdryApiService {
...
@@ -44,6 +52,8 @@ public class ZdryApiServiceImpl implements ZdryApiService {
@Value
(
"${updateSbxxUrl}"
)
@Value
(
"${updateSbxxUrl}"
)
private
String
updateSbxxUrl
;
private
String
updateSbxxUrl
;
@Value
(
"${locationUrl}"
)
private
String
locationUrl
;
@Autowired
@Autowired
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
...
@@ -130,6 +140,74 @@ public class ZdryApiServiceImpl implements ZdryApiService {
...
@@ -130,6 +140,74 @@ public class ZdryApiServiceImpl implements ZdryApiService {
return
"success"
;
return
"success"
;
}
}
@Override
public
MapRestResult
locationdata
(
String
deviceId
,
String
time_begin
)
{
List
<
LocationData
>
listResult
=
new
ArrayList
<>();
SimpleDateFormat
sf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
url
=
""
;
if
(
StringUtils
.
isNotEmpty
(
time_begin
)){
url
=
zdryUrl
+
locationUrl
+
"?device="
+
deviceId
+
"&time_begin="
+
time_begin
;
}
else
{
url
=
zdryUrl
+
locationUrl
+
"?device="
+
deviceId
;
}
try
{
String
resultString
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
if
(
StringUtils
.
isNotEmpty
(
resultString
))
{
JSONObject
result
=
JSONObject
.
parseObject
(
resultString
);
// 查看是否登录
if
(
result
.
containsKey
(
"error_code"
))
{
if
(
getToken
().
equals
(
"success"
)){
resultString
=
restTemplate
.
getForEntity
(
url
,
String
.
class
).
getBody
();
}
else
{
return
MapRestResult
.
build
(
200
,
"获取轨迹信息失败"
,
"1"
);
};
}
JSONObject
resultLast
=
JSONObject
.
parseObject
(
resultString
);
if
(
resultLast
.
containsKey
(
"objs"
))
{
JSONArray
jsonArray
=
resultLast
.
getJSONArray
(
"objs"
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++){
JSONObject
obj
=
jsonArray
.
getJSONObject
(
i
);
LocationData
locationData
=
new
LocationData
();
String
device
=
obj
.
getString
(
"device"
);
JSONObject
time
=
obj
.
getJSONObject
(
"created_at"
);
JSONObject
time1
=
obj
.
getJSONObject
(
"time_begin"
);
String
created_at
=
time
.
getString
(
"$date"
);
String
time_begins
=
time1
.
getString
(
"$date"
);
String
type
=
obj
.
getString
(
"type"
);
String
city
=
obj
.
getString
(
"city"
);
String
address
=
obj
.
getString
(
"address"
);
JSONObject
point
=
obj
.
getJSONObject
(
"point"
);
JSONArray
jsonArrayPoint
=
point
.
getJSONArray
(
"coordinates"
);
String
x
=
jsonArrayPoint
.
get
(
0
).
toString
();
String
y
=
jsonArrayPoint
.
get
(
1
).
toString
();
locationData
.
setDevice
(
device
);
locationData
.
setCreated_at
(
sf
.
format
(
new
Date
(
Long
.
parseLong
(
created_at
))));
locationData
.
setTime_begin
(
sf
.
format
(
new
Date
(
Long
.
parseLong
(
time_begins
))));
if
(
type
.
equals
(
"1"
)){
locationData
.
setType
(
"基站定位"
);
}
else
{
locationData
.
setType
(
"Gps定位"
);
}
locationData
.
setCity
(
city
);
locationData
.
setAddress
(
address
);
locationData
.
setX
(
x
);
locationData
.
setY
(
y
);
listResult
.
add
(
locationData
);
}
return
MapRestResult
.
build
(
200
,
"获取轨迹信息成功"
,
listResult
,
listResult
.
size
());
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"获取轨迹信息成功"
,
listResult
,
listResult
.
size
());
}
public
String
getToken
()
{
public
String
getToken
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
MediaType
type
=
MediaType
.
parseMediaType
(
"application/json"
);
MediaType
type
=
MediaType
.
parseMediaType
(
"application/json"
);
...
...
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