记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
2bb1eb8f
Commit
2bb1eb8f
authored
Nov 15, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
划卡优化
parent
db54c6ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
RedisUtil.java
...java/com.liquidnet.common.cache/redis/util/RedisUtil.java
+10
-1
DoTaskUtils.java
...n/java/com/liquidnet/service/chime/utils/DoTaskUtils.java
+15
-18
No files found.
liquidnet-bus-common/liquidnet-common-cache/liquidnet-common-cache-redis/src/main/java/com.liquidnet.common.cache/redis/util/RedisUtil.java
View file @
2bb1eb8f
...
...
@@ -32,5 +32,14 @@ public final class RedisUtil extends AbstractRedisUtil{
return
this
.
redisConfig
;
}
public
static
void
main
(
String
[]
args
)
{
String
[]
keys
=
{
"chime:per:openNum:Allow510093798172016641784538"
};
for
(
String
key
:
keys
)
{
long
value
=
key
.
hashCode
();
int
idx
=
((
int
)
(
value
^
(
value
>>>
32
))
%
250
);
System
.
out
.
printf
(
"\n[%s] - idx:%s"
,
key
,
idx
);
}
}
}
liquidnet-bus-service/liquidnet-service-chime/liquidnet-service-chime-impl/src/main/java/com/liquidnet/service/chime/utils/DoTaskUtils.java
View file @
2bb1eb8f
...
...
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
java.time.LocalDateTime
;
import
java.util.Calendar
;
@Slf4j
...
...
@@ -24,32 +25,28 @@ public class DoTaskUtils {
/**
* 划卡调任务
*
* @param currentUserId
*/
public
void
userAddNum
(
String
currentUserId
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
Long
timeout
=(
cal
.
getTimeInMillis
()-
System
.
currentTimeMillis
())/
1000
;
Integer
i
;
long
timeout
=
((
24
*
60
*
60
)
-
LocalDateTime
.
now
().
getSecond
());
Object
obj
=
redisUtil
.
get
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
);
int
slidCount
;
//判断当天是否有划卡
if
(
!
redisUtil
.
hasKey
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
))
{
i
=
1
;
redisUtil
.
set
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
,
i
,
timeout
);
}
else
{
i
=
(
Integer
)
redisUtil
.
get
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
)+
1
;
if
(
obj
==
null
)
{
slidCount
=
1
;
}
else
{
slidCount
=
(
int
)
obj
;
slidCount
=
slidCount
+
1
;
}
redisUtil
.
set
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
,
slidCount
,
timeout
);
redisUtil
.
set
(
ChimeConstant
.
REDIS_USER_OPEN_NUM
+
currentUserId
,
i
,
timeout
);
//获取用户是否调用过任务接口
boolean
hasKey
=
redisUtil
.
hasKey
(
ChimeConstant
.
REDIS_USER_TO_DOTASK
+
currentUserId
);
if
(!
hasKey
)
{
if
(!
hasKey
)
{
//满足10次调用接口,每天最多调用一次
if
(
i
>=
10
)
{
if
(
slidCount
>=
10
)
{
MultiValueMap
<
String
,
String
>
params
=
CollectionUtil
.
linkedMultiValueMapStringString
();
params
.
add
(
"uid"
,
currentUserId
);
params
.
add
(
"taskId"
,
3
+
""
);
...
...
@@ -60,9 +57,9 @@ public class DoTaskUtils {
//接口调用失败,重试
if
(!
success
)
{
this
.
userAddNum
(
currentUserId
);
}
else
{
}
else
{
//调用接口成功,记录
redisUtil
.
set
(
ChimeConstant
.
REDIS_USER_TO_DOTASK
+
currentUserId
,
1
,
timeout
);
redisUtil
.
set
(
ChimeConstant
.
REDIS_USER_TO_DOTASK
+
currentUserId
,
1
,
timeout
);
}
}
}
...
...
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