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 e10f0cb9
authored
Jan 04, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化Gps基站消费逻辑
1 parent
6c1dd31e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
src/main/java/cn/com/glsx/kafka/controller/GpsAndBsFlushController.java
src/main/java/cn/com/glsx/kafka/queue/remote/RemoteDeviceLocationService.java
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
src/main/java/cn/com/glsx/kafka/controller/GpsAndBsFlushController.java
View file @
e10f0cb
package
cn
.
com
.
glsx
.
kafka
.
controller
;
import
cn.com.glsx.kafka.service.BloomFilterService
;
import
cn.com.glsx.kafka.service.TransitHandleService
;
import
com.glsx.plat.common.annotation.SysLog
;
import
com.glsx.plat.common.enums.OperateType
;
import
com.glsx.plat.core.web.R
;
...
...
@@ -30,6 +31,9 @@ public class GpsAndBsFlushController {
@Autowired
private
BloomFilterService
bloomFilterService
;
@Autowired
private
TransitHandleService
transitHandleService
;
@GetMapping
(
value
=
"putsn"
)
@SysLog
(
module
=
MODULE
,
value
=
"同步单个设备号到布隆过滤器"
,
action
=
OperateType
.
QUERY
)
@ApiOperation
(
value
=
"同步单个设备号到布隆过滤器"
)
...
...
@@ -47,4 +51,13 @@ public class GpsAndBsFlushController {
bloomFilterService
.
syncAllData
();
return
R
.
ok
();
}
@GetMapping
(
value
=
"/syncalldevicelocation"
)
@SysLog
(
module
=
MODULE
,
value
=
"同步所有设备号redis"
,
action
=
OperateType
.
QUERY
)
@ApiOperation
(
value
=
"同步所有设备号到redis"
)
public
R
syncAllDeviceLocationData
()
{
log
.
info
(
"调用接口同步所有上点数据到redis==="
);
transitHandleService
.
syncAllDeviceLocationData
();
return
R
.
ok
();
}
}
src/main/java/cn/com/glsx/kafka/queue/remote/RemoteDeviceLocationService.java
View file @
e10f0cb
...
...
@@ -48,4 +48,18 @@ public class RemoteDeviceLocationService {
deviceLocationClient
.
dropLibrary
(
deviceLocationDtos
);
}
/**
* 获取数据库中的所有设备上点数据
*
* @return 上点数据集合
*/
public
List
<
DeviceLocationDto
>
getAllDeviceLocationData
()
{
R
<
List
<
DeviceLocationDto
>>
allDeviceLocationDataR
=
deviceLocationClient
.
getAllDeviceLocationData
();
List
<
DeviceLocationDto
>
allDeviceLocationList
=
allDeviceLocationDataR
.
getDataList
(
new
TypeToken
<
List
<
DeviceLocationDto
>>()
{
}.
getType
());
if
(
CollectionUtil
.
isEmpty
(
allDeviceLocationList
))
{
allDeviceLocationList
=
Lists
.
newArrayList
();
}
return
allDeviceLocationList
;
}
}
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
View file @
e10f0cb
...
...
@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -48,6 +49,14 @@ public class TransitHandleService {
*/
private
static
final
int
STEP
=
60000
;
/**
* 初始化的时候 同步数据库中的设备上点数据到redis
*/
@PostConstruct
public
void
init
()
{
syncAllDeviceLocationData
();
}
/**
* 处理GPS和基站的数据
...
...
@@ -258,4 +267,14 @@ public class TransitHandleService {
private
String
setKey
(
String
sn
,
String
type
)
{
return
"gpsbs_"
+
sn
+
"_"
+
type
;
}
public
void
syncAllDeviceLocationData
()
{
List
<
DeviceLocationDto
>
deviceLocationList
=
remoteDeviceLocationService
.
getAllDeviceLocationData
();
deviceLocationList
.
forEach
(
deviceLocationDto
->
{
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
(),
Constants
.
GPS
),
deviceLocationDto
);
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
(),
Constants
.
BS
),
deviceLocationDto
);
redisUtils
.
set
(
setKey
(
deviceLocationDto
.
getSn
(),
Constants
.
STAY_STATUS
),
deviceLocationDto
);
});
log
.
info
(
"同步数据库中的上点数据到redis结束===同步条数==="
+
deviceLocationList
.
size
());
}
}
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