Commit 3d35f69e authored by renjie's avatar renjie

ip健康检查过滤已过期ip

parent f423ad8b
...@@ -25,6 +25,7 @@ import org.slf4j.Logger; ...@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -238,7 +239,11 @@ public class BrowserTask { ...@@ -238,7 +239,11 @@ public class BrowserTask {
if (ipResourceRepository.healthLock(ipResource)) { if (ipResourceRepository.healthLock(ipResource)) {
try { try {
QueryIpUrlList queryIpUrlList = queryIpUrlListRepository.findAll().get(0); QueryIpUrlList queryIpUrlList = queryIpUrlListRepository.findAll().get(0);
if (ipResource.isSpecialLine()) { if (ipResource.getValidTime() <= Instant.now().toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) {
ipResource.setStatus(1);
ipResourceRepository.save(ipResource);
}
else if (ipResource.isSpecialLine()) {
Trans trans = new Trans(ipResource.getProxyUsername(), ipResource.getProxyPassword()); Trans trans = new Trans(ipResource.getProxyUsername(), ipResource.getProxyPassword());
String sp_result = trans.get(queryIpUrlList.getUrl()); String sp_result = trans.get(queryIpUrlList.getUrl());
int failTime = 0; int failTime = 0;
...@@ -296,7 +301,7 @@ public class BrowserTask { ...@@ -296,7 +301,7 @@ public class BrowserTask {
IpCountRecord ipCountRecord = new IpCountRecord(); IpCountRecord ipCountRecord = new IpCountRecord();
ipCountRecord.setUsername(x.getName()); ipCountRecord.setUsername(x.getName());
ipCountRecord.setTimestamp(Instant.now().toEpochMilli()); ipCountRecord.setTimestamp(Instant.now().toEpochMilli());
long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeleted(x.getName(), false); long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(x.getName(), false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.countAllByOwner(x.getName()); long ipcount_all = ipResourceRepository.countAllByOwner(x.getName());
ipCountRecord.setIp_all(ipcount_all); ipCountRecord.setIp_all(ipcount_all);
ipCountRecord.setIp_using(ipcount_using); ipCountRecord.setIp_using(ipcount_using);
...@@ -305,7 +310,7 @@ public class BrowserTask { ...@@ -305,7 +310,7 @@ public class BrowserTask {
IpCountRecord ipCountRecord = new IpCountRecord(); IpCountRecord ipCountRecord = new IpCountRecord();
ipCountRecord.setUsername("all"); ipCountRecord.setUsername("all");
ipCountRecord.setTimestamp(Instant.now().toEpochMilli()); ipCountRecord.setTimestamp(Instant.now().toEpochMilli());
long ipcount_using = ipResourceRepository.countAllByIsDeleted(false); long ipcount_using = ipResourceRepository.countAllByIsDeletedAndValidTimeGreaterThan(false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.count(); long ipcount_all = ipResourceRepository.count();
ipCountRecord.setIp_using(ipcount_using); ipCountRecord.setIp_using(ipcount_using);
ipCountRecord.setIp_all(ipcount_all); ipCountRecord.setIp_all(ipcount_all);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment