Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-kafkaconsumer-gpsbs
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 0a5b0145
authored
Dec 21, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化gps基站保存逻辑
1 parent
98c0b8aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
View file @
0a5b014
...
@@ -49,11 +49,10 @@ public class TransitHandleService {
...
@@ -49,11 +49,10 @@ public class TransitHandleService {
*/
*/
public
void
handleGpsAndBsData
(
DeviceLocationDto
deviceLocationDto
)
{
public
void
handleGpsAndBsData
(
DeviceLocationDto
deviceLocationDto
)
{
DeviceLocationDto
deviceLocationCache
=
(
DeviceLocationDto
)
redisUtils
.
get
(
setKey
(
deviceLocationDto
.
getSn
()));
DeviceLocationDto
deviceLocationCache
=
(
DeviceLocationDto
)
redisUtils
.
get
(
setKey
(
deviceLocationDto
.
getSn
()));
if
(
ObjectUtil
.
is
Empty
(
deviceLocationCache
))
{
if
(
ObjectUtil
.
is
Null
(
deviceLocationCache
))
{
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
()),
deviceLocationDto
);
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
()),
deviceLocationDto
);
deviceLocationMap
.
put
(
deviceLocationDto
.
getSn
(),
deviceLocationDto
);
deviceLocationMap
.
put
(
deviceLocationDto
.
getSn
(),
deviceLocationDto
);
}
}
else
{
// gps时间比缓存中Gps的时间大就更新缓存的时间
// gps时间比缓存中Gps的时间大就更新缓存的时间
Date
lastGpsTime
=
deviceLocationDto
.
getLastGpsTime
();
Date
lastGpsTime
=
deviceLocationDto
.
getLastGpsTime
();
Date
lastGpsTimeCache
=
deviceLocationCache
.
getLastGpsTime
();
Date
lastGpsTimeCache
=
deviceLocationCache
.
getLastGpsTime
();
...
@@ -71,8 +70,9 @@ public class TransitHandleService {
...
@@ -71,8 +70,9 @@ public class TransitHandleService {
// 重新设置回缓存
// 重新设置回缓存
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
()),
deviceLocationCache
);
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
()),
deviceLocationCache
);
deviceLocationMap
.
put
(
deviceLocationDto
.
getSn
(),
deviceLocationCache
);
deviceLocationMap
.
put
(
deviceLocationDto
.
getSn
(),
deviceLocationCache
);
}
// 当数据大小为
100个
的时候 保存一次
// 当数据大小为
500个 或者 时间间隔3秒
的时候 保存一次
if
(
deviceLocationMap
.
size
()
>=
500
||
System
.
currentTimeMillis
()
>=
tempTime
+
STEP
)
{
if
(
deviceLocationMap
.
size
()
>=
500
||
System
.
currentTimeMillis
()
>=
tempTime
+
STEP
)
{
log
.
info
(
"开始插入或者更新Gps和基站的数据大小==="
+
deviceLocationMap
.
size
());
log
.
info
(
"开始插入或者更新Gps和基站的数据大小==="
+
deviceLocationMap
.
size
());
remoteDeviceLocationService
.
saveOrUpdateDeviceLocationData
(
deviceLocationMap
.
values
());
remoteDeviceLocationService
.
saveOrUpdateDeviceLocationData
(
deviceLocationMap
.
values
());
...
...
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