|
@@ -11,6 +11,9 @@ import org.apache.commons.lang.math.NumberUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.ZonedDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -32,8 +35,15 @@ public class JobService {
|
|
|
public void syncViewCount() {
|
|
|
ArticleContentLinkExample example = new ArticleContentLinkExample();
|
|
|
|
|
|
- long now = System.currentTimeMillis();
|
|
|
- long time = now - (now % seconds1d) - seconds7d;
|
|
|
+
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ // 计算7天前的日期
|
|
|
+ LocalDate dateSevenDaysAgo = today.minusDays(7);
|
|
|
+ // 将日期转换为当天开始的时间(00:00:00)并指定时区
|
|
|
+ ZonedDateTime zonedDateTime = dateSevenDaysAgo.atStartOfDay(ZoneId.systemDefault());
|
|
|
+ // 将ZonedDateTime转换为时间戳(毫秒)
|
|
|
+ long time = zonedDateTime.toInstant().toEpochMilli();
|
|
|
+
|
|
|
|
|
|
example.createCriteria().andCreateTimeGreaterThanOrEqualTo(time);
|
|
|
List<ArticleContentLink> links = articleContentLinkMapper.selectByExample(example);
|