|
- package com.ningdatech.kqapi.scheduler.task;
-
- import cn.hutool.core.date.StopWatch;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.ningdatech.kqapi.scheduler.contants.TaskContant;
- import com.ningdatech.kqapi.zzsfw.entity.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
- import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Component;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
-
- /**
- * @author ZPF
- * @since 2023/08/31 18:16
- */
- @Component
- @Slf4j
- @RequiredArgsConstructor
- public class RemoveMattersTask {
-
- @Value("${hostname}")
- public String HOST;
-
- @Value("${spring.profiles.active}")
- public String active;
-
- @Autowired
- private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;
-
- /**
- * 每天
- */
- @Scheduled(cron = "0 50 14 * * ?")
- public void doTask() throws UnknownHostException {
- if (!HOST.equals(InetAddress.getLocalHost().getHostName())) {
- log.info("定时器没开启或者host不对! {}:{}",
- HOST,InetAddress.getLocalHost().getHostName());
- return;
- }
- if(!TaskContant.PROD.equals(active)){
- log.info("非正式环境不用删除!");
- return;
- }
-
- StopWatch stopWatch = new StopWatch();
- stopWatch.start();
-
- log.info("删除事项表 所有数据 等待新数据推上来");
- if(kqService.remove(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class))){
- log.info("删除成功");
- }
-
- log.info("当前表里还有数据 :{}条",kqService.count());
-
- stopWatch.stop();
- log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds());
- }
- }
|