Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
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
Administrator
browser-backend
Commits
97673e0b
Commit
97673e0b
authored
Jan 22, 2021
by
huangjiamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
七天过期清除改为三天过期清除
parent
a2eea814
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+6
-6
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+4
-4
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+2
-2
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
97673e0b
...
...
@@ -675,14 +675,14 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
1
*
60
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
x
.
setStatus
(
3
);
// 1.2 ip资源在未来
七
天内到期,且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
// 1.2 ip资源在未来
3
天内到期,且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
2
);
}
// 1.3 ip资源在
七
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
// 1.3 ip资源在
3
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
if
(
x
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto
=
new
IpResourceRequestDto
();
ipResourceRequestDto
.
setAddr
(
Arrays
.
asList
(
x
.
getAddr
()));
...
...
@@ -856,9 +856,9 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
2
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
())
{
deleteExpiredIp
(
username
,
ipResourceRequestDto
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
())
{
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
1
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
97673e0b
...
...
@@ -577,16 +577,16 @@ public class ShopServiceImpl implements ShopService {
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
// 如果 ip资源非空 且 addr 也非空
if
(
ipResource
!=
null
&&
!
StringUtils
.
isEmpty
(
ipResource
.
getAddr
()))
{
// 1. ip资源在未来
七
天内到期 且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
// 1. ip资源在未来
3
天内到期 且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
ipResource
.
setStatus
(
2
);
//ipResourceRepository.save(ipResource);
pageIpResourceListToSave
.
add
(
ipResource
);
}
// 2. ip资源在
七
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
// 2. ip资源在
3
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
ipResourceRequestDto1
.
setAddr
(
Arrays
.
asList
(
ipResource
.
getAddr
()));
...
...
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
97673e0b
...
...
@@ -347,11 +347,11 @@ public class BrowserTask {
* 每天凌晨1点查询 {@code validTime}早于7天前,并且未被删除的ip。
* 调用{@code deleteOverdueIp}删除IP资源
*/
@Scheduled
(
cron
=
"0 0
/1 * * * ?
"
)
@Scheduled
(
cron
=
"0 0
* * * ? *
"
)
public
void
deleteOverdueIps
()
{
String
logs
=
"【deleteOverdueIps】 "
;
List
<
IpResource
>
list
=
ipResourceRepository
.
findByValidTimeLessThanAndIsDeleted
(
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
(),
false
);
.
findByValidTimeLessThanAndIsDeleted
(
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
(),
false
);
log
.
error
(
"Scheduled {}, list size : {}"
,
logs
,
list
.
size
());
list
.
forEach
(
this
::
deleteOverdueIp
);
...
...
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