Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
signal
traffic-signal-platform
Commits
79b434e8
Commit
79b434e8
authored
Jun 21, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 微观大数据平台-行程时间日志打印
parent
728f850f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
RedisUtils.java
...ervice/src/main/java/net/wanji/opt/common/RedisUtils.java
+17
-11
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/common/RedisUtils.java
View file @
79b434e8
package
net
.
wanji
.
opt
.
common
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.opt.dto.CrossEventDTO
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.ZSetOperations
;
...
...
@@ -17,6 +17,7 @@ import java.util.Set;
* Created on 2019/4/29 20:34
*/
@Component
@Slf4j
public
class
RedisUtils
{
@Resource
...
...
@@ -25,19 +26,24 @@ public class RedisUtils {
/**
* 7号库获取最大 score zset 元素
*/
public
Object
getMaxScoreElement
(
String
redisKey
)
throws
JsonProcessingException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ZSetOperations
<
String
,
Object
>
zSetOps
=
redis7Template
.
opsForZSet
();
Set
<
Object
>
result
=
zSetOps
.
reverseRange
(
redisKey
,
0
,
-
1
);
public
Object
getMaxScoreElement
(
String
redisKey
)
throws
Exception
{
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ZSetOperations
<
String
,
Object
>
zSetOps
=
redis7Template
.
opsForZSet
();
Set
<
Object
>
result
=
zSetOps
.
reverseRange
(
redisKey
,
0
,
-
1
);
if
(
result
!=
null
&&
!
result
.
isEmpty
())
{
for
(
Object
o
:
result
)
{
CrossEventDTO
dto
=
objectMapper
.
readValue
(
o
.
toString
(),
CrossEventDTO
.
class
);
String
msgType
=
dto
.
getMsgType
();
if
(
msgType
.
startsWith
(
"50"
))
{
return
o
;
if
(
result
!=
null
&&
!
result
.
isEmpty
())
{
for
(
Object
o
:
result
)
{
CrossEventDTO
dto
=
objectMapper
.
readValue
(
o
.
toString
(),
CrossEventDTO
.
class
);
String
msgType
=
dto
.
getMsgType
();
if
(
msgType
.
startsWith
(
"50"
))
{
return
o
;
}
}
}
log
.
error
(
"redis获取数据key:{}, 获取value:{}"
,
redisKey
,
result
);
}
catch
(
Exception
e
)
{
//throw new RuntimeException(e);
}
return
null
;
}
...
...
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