|
@@ -14,7 +14,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.http.client.CookieStore;
|
|
|
import org.apache.http.impl.client.BasicCookieStore;
|
|
|
import org.apache.http.impl.cookie.BasicClientCookie;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -63,6 +62,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
chromeOptions.addArguments("--headless");
|
|
|
chromeOptions.addArguments("--incognito");
|
|
|
+ chromeOptions.addArguments("--disable-dev-shm-usage");
|
|
|
chromeOptions.addArguments("--disable-gpu");
|
|
|
chromeOptions.addArguments("--window-size=1920,1080");
|
|
|
chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
|
|
@@ -88,11 +88,10 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
|
|
|
Set<Cookie> cookies = webDriver.manage().getCookies();
|
|
|
Iterator iterator = cookies.iterator();
|
|
|
- CookieStore cookieStore = new BasicCookieStore();
|
|
|
while (iterator.hasNext()) {
|
|
|
String cookieStr = iterator.next().toString();
|
|
|
String[] cookieArray = cookieStr.split(";");
|
|
|
- Map<String, String> cookieMap = new HashMap<String, String>();
|
|
|
+ Map<String, String> cookieMap = new HashMap<>();
|
|
|
for (String cookie : cookieArray) {
|
|
|
String[] kv = cookie.split("=");
|
|
|
if (kv.length > 1) {
|
|
@@ -111,7 +110,6 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
loginStatus = false;
|
|
|
} finally {
|
|
|
webDriver.manage().deleteAllCookies();
|
|
|
-// webDriver.close();
|
|
|
webDriver.quit();
|
|
|
}
|
|
|
return loginStatus;
|
|
@@ -121,12 +119,10 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
public boolean getAccount(int currentPage) {
|
|
|
boolean hasNextPage = false;
|
|
|
try {
|
|
|
- if (currentPage == 1) {
|
|
|
- if (!loginAgent()) {
|
|
|
- return hasNextPage;
|
|
|
- }
|
|
|
+ if (currentPage == 1&&!loginAgent()) {
|
|
|
+ return hasNextPage;
|
|
|
}
|
|
|
- Map<String, String> headerMap = new HashMap<String, String>();
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
headerMap.put("Accept", "application/json");
|
|
|
headerMap.put("Accept-Encoding", "gzip, deflate, br");
|
|
|
headerMap.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
|
@@ -162,7 +158,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
agentAccount.setTotalBalance(agentAccount.getTotalBalance().divide(new BigDecimal(1000)));
|
|
|
accountList.add(agentAccount);
|
|
|
}
|
|
|
- if (accountList != null && accountList.size() > 0) {
|
|
|
+ if (!accountList.isEmpty()) {
|
|
|
kuaishouAgentAccountMapper.replaceBatch(accountList);
|
|
|
}
|
|
|
}
|
|
@@ -180,7 +176,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
return;
|
|
|
}
|
|
|
String currentDate = startDate;
|
|
|
- Map<String, String> headerMap = new HashMap<String, String>();
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
headerMap.put("Accept", "application/json");
|
|
|
headerMap.put("Accept-Encoding", "gzip, deflate, br");
|
|
|
headerMap.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
|
@@ -250,7 +246,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
- if (reportList != null && reportList.size() > 0) {
|
|
|
+ if (!reportList.isEmpty()) {
|
|
|
replaceBatch(reportList);
|
|
|
}
|
|
|
}
|