From fdd33cf180618b3d7ff1f99295163881de3bf63c Mon Sep 17 00:00:00 2001 From: 王明元 <97082371@qq.com> Date: Fri, 12 Aug 2022 18:03:20 +0800 Subject: [PATCH] 2022年8月12日18:02:07 增加查询未完成数据抓取账号列表接口 --- src/main/java/cn/fw/freya/controller/OtherController.java | 11 +++++++++++ src/main/java/cn/fw/freya/service/crawl/impl/Common.java | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/src/main/java/cn/fw/freya/controller/OtherController.java b/src/main/java/cn/fw/freya/controller/OtherController.java index f378ae8..f35a4a0 100644 --- a/src/main/java/cn/fw/freya/controller/OtherController.java +++ b/src/main/java/cn/fw/freya/controller/OtherController.java @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -180,4 +181,14 @@ public class OtherController { return common.getWithoutPlaybackLive(type, durationThreshold); } + /** + * 获取未完成抓取的账号分布 + * + * @return 未完成抓取的账号分布 + */ + @GetMapping("/getUndoneAccount") + public Map> getUndoneAccount() { + return common.getUndoneAccount(); + } + } diff --git a/src/main/java/cn/fw/freya/service/crawl/impl/Common.java b/src/main/java/cn/fw/freya/service/crawl/impl/Common.java index 28c510e..4bf5dc4 100644 --- a/src/main/java/cn/fw/freya/service/crawl/impl/Common.java +++ b/src/main/java/cn/fw/freya/service/crawl/impl/Common.java @@ -5,6 +5,7 @@ import cn.fw.freya.dao.AccountDao; import cn.fw.freya.dao.CookieDao; import cn.fw.freya.dao.LivePoolDao; import cn.fw.freya.dao.VideoPoolDao; +import cn.fw.freya.enums.AccountTypeEnum; import cn.fw.freya.model.data.Account; import cn.fw.freya.model.data.FwCookie; import cn.fw.freya.model.data.ResponseReceived; @@ -359,4 +360,34 @@ public class Common { accountDao.save(waitSaveAccount);// 不存在, 则保存该账号 } + /** + * 获取未完成抓取的账号分布 + * + * @return 未完成抓取的账号分布 + */ + public Map> getUndoneAccount() { + Map> undoneAccountMap = new HashMap<>(); + List accountList = accountDao.findNotUseAccount(); + if (CollectionUtils.isEmpty(accountList)) + return undoneAccountMap; + accountList.stream() + .collect(Collectors.groupingBy(Account::getType)) + .forEach((k, v) -> { + String key = null; + if (Objects.equals(k, AccountTypeEnum.KS.getValue())) + key = "「快手」"; + if (Objects.equals(k, AccountTypeEnum.DY.getValue())) + key = "「抖音」"; + if (Objects.equals(k, AccountTypeEnum.DCD.getValue())) + key = "「懂车帝」"; + if (Objects.equals(k, AccountTypeEnum.BILIBILI.getValue())) + key = "「哔哩哔哩」"; + undoneAccountMap.put(key, v.stream() + .map(Account::getAccountNo) + .sorted() + .collect(Collectors.toList()) + ); + }); + return undoneAccountMap; + } } -- libgit2 0.22.2