Commit 13ffb6699233d96d3a59118159b0dace6ddc64eb

Authored by 王明元
1 parent a6c412db

2022年7月22日18:14:38 登录账号成功, 检查列表是否包含该账号, 不包含则将该账号加入列表

src/main/java/cn/fw/freya/service/crawl/impl/BilibiliCrawl.java
... ... @@ -111,8 +111,10 @@ public class BilibiliCrawl implements CrawlStrategy {
111 111 final JSONObject userInfo = this.getUserInfo(accountNo, this.processCookiesToString(common.getTempCookies(driver, accountNo, this.getType().getValue())));
112 112 assert userInfo != null;
113 113 if (Objects.equals(accountNo, userInfo.get("userId"))) {
114   - common.saveCookie(driver, accountNo, this.getType().getValue());
115   - accountService.updateAccountCookiesStatus(accountNo, this.getType().getValue(), true);
  114 + Integer type = this.getType().getValue();
  115 + common.saveCookie(driver, accountNo, type);
  116 + accountService.updateAccountCookiesStatus(accountNo, type, true);
  117 + common.whenLoginCheckAccountExist(accountNo, type);
116 118 this.exitBrowser(accountNo, null);
117 119 return true;
118 120 } else {
... ...
src/main/java/cn/fw/freya/service/crawl/impl/Common.java
... ... @@ -318,4 +318,27 @@ public class Common {
318 318 return livePoolDao.getWithoutPlaybackLive(type, durationThreshold);
319 319 }
320 320  
  321 + /**
  322 + * 当账号登录成功, 检查今天同步了的账号列表中是否包含该账号
  323 + *
  324 + * @param accountNo 账号
  325 + * @param type 账号类型
  326 + * @return 结果
  327 + */
  328 + public void whenLoginCheckAccountExist(String accountNo, Integer type) {
  329 + Account account = accountDao.findByAccountNoAndType(accountNo, type);
  330 + if (Objects.nonNull(account))
  331 + return;
  332 + accountDao.save(Account.builder()
  333 + .cookiesStatus(true)
  334 + .accountNo(accountNo)
  335 + .type(type)
  336 + .fansCnt(null)
  337 + .accountName(null)
  338 + .reportDate(null)
  339 + .done(false)
  340 + .build()
  341 + );// 不存在, 则保存该账号
  342 + }
  343 +
321 344 }
... ...
src/main/java/cn/fw/freya/service/crawl/impl/DongCheDiCrawl.java
... ... @@ -113,8 +113,10 @@ public class DongCheDiCrawl implements CrawlStrategy {
113 113 final JSONObject userInfo = this.getUserInfo(accountNo, this.processCookiesToString(common.getTempCookies(driver, accountNo, this.getType().getValue())));
114 114 assert userInfo != null;
115 115 if (Objects.equals(accountNo, userInfo.get("ttId"))) {
116   - common.saveCookie(driver, accountNo, this.getType().getValue());
117   - accountService.updateAccountCookiesStatus(accountNo, this.getType().getValue(), true);
  116 + Integer type = this.getType().getValue();
  117 + common.saveCookie(driver, accountNo, type);
  118 + accountService.updateAccountCookiesStatus(accountNo, type, true);
  119 + common.whenLoginCheckAccountExist(accountNo, type);
118 120 this.exitBrowser(accountNo, null);
119 121 return true;
120 122 } else {
... ...
src/main/java/cn/fw/freya/service/crawl/impl/DouYinCrawl.java
... ... @@ -112,8 +112,10 @@ public class DouYinCrawl implements CrawlStrategy {
112 112 this.exitBrowser(accountNo, null);
113 113 throw new BusinessException("请联系抖音账号为: " + accountNo + " 的员工登录'抖音创作服务平台'解锁");
114 114 } else {
115   - common.saveCookie(driver, accountNo, this.getType().getValue());// 保存该用户的cookies
116   - accountService.updateAccountCookiesStatus(accountNo, this.getType().getValue(), true);
  115 + Integer type = this.getType().getValue();
  116 + common.saveCookie(driver, accountNo, type);// 保存该用户的cookies
  117 + accountService.updateAccountCookiesStatus(accountNo, type, true);
  118 + common.whenLoginCheckAccountExist(accountNo, type);
117 119 this.exitBrowser(accountNo, null);
118 120 return true;
119 121 }
... ...
src/main/java/cn/fw/freya/service/crawl/impl/KuaiShouCrawl.java
... ... @@ -233,8 +233,10 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle {
233 233 subLength = 4;
234 234 }
235 235 if (accountNo.equals(accountText.substring(subLength))) {
236   - common.saveCookie(driver, accountNo, this.getType().getValue());// 保存该用户的cookies
237   - accountService.updateAccountCookiesStatus(accountNo, this.getType().getValue(), true);
  236 + Integer type = this.getType().getValue();
  237 + common.saveCookie(driver, accountNo, type);// 保存该用户的cookies
  238 + accountService.updateAccountCookiesStatus(accountNo, type, true);
  239 + common.whenLoginCheckAccountExist(accountNo, type);
238 240 this.exitBrowser(accountNo, null);
239 241 return true;
240 242 } else {
... ...
src/main/java/cn/fw/freya/service/rpc/ReportRpcService.java
... ... @@ -165,6 +165,7 @@ public class ReportRpcService {
165 165 .liveEndTime(item.getLiveEndTime())
166 166 .build()
167 167 ).collect(Collectors.toList()));
  168 + //System.out.println(JSON.toJSONString(dto));
168 169 HttpConfig config = HttpConfig.custom()
169 170 .encoding(java.nio.charset.StandardCharsets.UTF_8.displayName())
170 171 .url(getBaseUrl() + PathConstant.REPORT_LIVE)
... ...
src/main/java/cn/fw/freya/utils/CronCheckUtil.java
... ... @@ -43,7 +43,7 @@ public class CronCheckUtil {
43 43 */
44 44 public static void main(String[] args) {
45 45 DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
46   - final List<LocalDateTime> runtimeList = CronCheckUtil.getRuntimeList("0 15 0 * * ?", LocalDateTime.now(), 10);
  46 + final List<LocalDateTime> runtimeList = CronCheckUtil.getRuntimeList("0 0 * * * ?", LocalDateTime.now(), 100);
47 47 runtimeList.forEach(item -> System.out.println(dateTimeFormatter.format(item)));
48 48 }
49 49 }
... ...