Commit fb8d91f1f28f8fa034db08f246dcde852d2bf5b4
1 parent
13ffb669
2022年7月22日18:32:18 写入账号时候加强逻辑判断
Showing
1 changed file
with
28 additions
and
10 deletions
src/main/java/cn/fw/freya/service/crawl/impl/Common.java
... | ... | @@ -11,6 +11,7 @@ import cn.fw.freya.model.data.ResponseReceived; |
11 | 11 | import cn.fw.freya.model.data.pool.LivePool; |
12 | 12 | import cn.fw.freya.model.data.pool.VideoPool; |
13 | 13 | import cn.fw.freya.model.dto.rpc.ReportAccountDto; |
14 | +import cn.fw.freya.utils.DateUtil; | |
14 | 15 | import com.alibaba.fastjson.JSON; |
15 | 16 | import com.alibaba.fastjson.JSONObject; |
16 | 17 | import lombok.RequiredArgsConstructor; |
... | ... | @@ -37,6 +38,9 @@ import org.springframework.transaction.annotation.Transactional; |
37 | 38 | import org.springframework.util.CollectionUtils; |
38 | 39 | |
39 | 40 | import java.io.IOException; |
41 | +import java.time.LocalDate; | |
42 | +import java.time.LocalDateTime; | |
43 | +import java.time.LocalTime; | |
40 | 44 | import java.util.*; |
41 | 45 | import java.util.logging.Level; |
42 | 46 | import java.util.stream.Collectors; |
... | ... | @@ -329,16 +333,30 @@ public class Common { |
329 | 333 | Account account = accountDao.findByAccountNoAndType(accountNo, type); |
330 | 334 | if (Objects.nonNull(account)) |
331 | 335 | 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 | - );// 不存在, 则保存该账号 | |
336 | + Date now = new Date(); | |
337 | + Date date = DateUtil.localDateTime2Date(LocalDateTime.of(LocalDate.now(), LocalTime.of(12, 30, 0))); | |
338 | + Account waitSaveAccount; | |
339 | + if (now.compareTo(date) >= 0)// 当前时间>=12:30 | |
340 | + waitSaveAccount = Account.builder() | |
341 | + .cookiesStatus(true) | |
342 | + .accountNo(accountNo) | |
343 | + .type(type) | |
344 | + .fansCnt(null) | |
345 | + .accountName(null) | |
346 | + .reportDate(null) | |
347 | + .done(false) | |
348 | + .build(); | |
349 | + else | |
350 | + waitSaveAccount = Account.builder() | |
351 | + .cookiesStatus(true) | |
352 | + .accountNo(accountNo) | |
353 | + .type(type) | |
354 | + .fansCnt(0) | |
355 | + .accountName(null) | |
356 | + .reportDate(now) | |
357 | + .done(true) | |
358 | + .build(); | |
359 | + accountDao.save(waitSaveAccount);// 不存在, 则保存该账号 | |
342 | 360 | } |
343 | 361 | |
344 | 362 | } | ... | ... |