Commit fdd33cf180618b3d7ff1f99295163881de3bf63c

Authored by 王明元
1 parent 3941903c

2022年8月12日18:02:07 增加查询未完成数据抓取账号列表接口

src/main/java/cn/fw/freya/controller/OtherController.java
... ... @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat;
29 29 import java.time.LocalDate;
30 30 import java.util.Date;
31 31 import java.util.List;
  32 +import java.util.Map;
32 33 import java.util.Set;
33 34 import java.util.stream.Collectors;
34 35  
... ... @@ -180,4 +181,14 @@ public class OtherController {
180 181 return common.getWithoutPlaybackLive(type, durationThreshold);
181 182 }
182 183  
  184 + /**
  185 + * 获取未完成抓取的账号分布
  186 + *
  187 + * @return 未完成抓取的账号分布
  188 + */
  189 + @GetMapping("/getUndoneAccount")
  190 + public Map<String, List<String>> getUndoneAccount() {
  191 + return common.getUndoneAccount();
  192 + }
  193 +
183 194 }
... ...
src/main/java/cn/fw/freya/service/crawl/impl/Common.java
... ... @@ -5,6 +5,7 @@ import cn.fw.freya.dao.AccountDao;
5 5 import cn.fw.freya.dao.CookieDao;
6 6 import cn.fw.freya.dao.LivePoolDao;
7 7 import cn.fw.freya.dao.VideoPoolDao;
  8 +import cn.fw.freya.enums.AccountTypeEnum;
8 9 import cn.fw.freya.model.data.Account;
9 10 import cn.fw.freya.model.data.FwCookie;
10 11 import cn.fw.freya.model.data.ResponseReceived;
... ... @@ -359,4 +360,34 @@ public class Common {
359 360 accountDao.save(waitSaveAccount);// 不存在, 则保存该账号
360 361 }
361 362  
  363 + /**
  364 + * 获取未完成抓取的账号分布
  365 + *
  366 + * @return 未完成抓取的账号分布
  367 + */
  368 + public Map<String, List<String>> getUndoneAccount() {
  369 + Map<String, List<String>> undoneAccountMap = new HashMap<>();
  370 + List<Account> accountList = accountDao.findNotUseAccount();
  371 + if (CollectionUtils.isEmpty(accountList))
  372 + return undoneAccountMap;
  373 + accountList.stream()
  374 + .collect(Collectors.groupingBy(Account::getType))
  375 + .forEach((k, v) -> {
  376 + String key = null;
  377 + if (Objects.equals(k, AccountTypeEnum.KS.getValue()))
  378 + key = "「快手」";
  379 + if (Objects.equals(k, AccountTypeEnum.DY.getValue()))
  380 + key = "「抖音」";
  381 + if (Objects.equals(k, AccountTypeEnum.DCD.getValue()))
  382 + key = "「懂车帝」";
  383 + if (Objects.equals(k, AccountTypeEnum.BILIBILI.getValue()))
  384 + key = "「哔哩哔哩」";
  385 + undoneAccountMap.put(key, v.stream()
  386 + .map(Account::getAccountNo)
  387 + .sorted()
  388 + .collect(Collectors.toList())
  389 + );
  390 + });
  391 + return undoneAccountMap;
  392 + }
362 393 }
... ...