liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/task/BannerTaskUtil.java
@@ -1,14 +1,22 @@
package com.xiaopeng.operation.utils.task;
import com.xiaopeng.api.model.operation.XpBanner;
import com.xiaopeng.api.vo.operation.XpLogMessage;
import com.xiaopeng.common.core.constant.CacheConstants;
import com.xiaopeng.operation.service.XpBannerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Set;
/**
 * @author 无关风月
@@ -20,6 +28,9 @@
    @Autowired
    private XpBannerService bannerService;
    @Resource
    private MongoTemplate mongoTemplate;
    /**
@@ -48,4 +59,14 @@
    }
    /**
     * 删除移动端日志
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void removeLogMessage() {
        //删除大于2天的日志记录
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime twoDayAgo = now.minusDays(2);
        mongoTemplate.remove(new Query(Criteria.where("timestamp").lt(twoDayAgo.toEpochSecond(ZoneOffset.of("+8")))), XpLogMessage.class);
    }
}