柯桥增值式服务
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

64 řádky
2.0KB

  1. package com.ningdatech.kqapi.scheduler.task;
  2. import cn.hutool.core.date.StopWatch;
  3. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  4. import com.ningdatech.kqapi.scheduler.contants.TaskContant;
  5. import com.ningdatech.kqapi.zzsfw.entity.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;
  6. import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService;
  7. import lombok.RequiredArgsConstructor;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.beans.factory.annotation.Value;
  11. import org.springframework.scheduling.annotation.Scheduled;
  12. import org.springframework.stereotype.Component;
  13. import java.net.InetAddress;
  14. import java.net.UnknownHostException;
  15. /**
  16. * @author ZPF
  17. * @since 2023/08/31 18:16
  18. */
  19. @Component
  20. @Slf4j
  21. @RequiredArgsConstructor
  22. public class RemoveMattersTask {
  23. @Value("${hostname}")
  24. public String HOST;
  25. @Value("${spring.profiles.active}")
  26. public String active;
  27. @Autowired
  28. private IDscSxAdsShareItemQltQlsxCommonIDVKqService kqService;
  29. /**
  30. * 每天
  31. */
  32. @Scheduled(cron = "0 50 14 * * ?")
  33. public void doTask() throws UnknownHostException {
  34. if (!HOST.equals(InetAddress.getLocalHost().getHostName())) {
  35. log.info("定时器没开启或者host不对! {}:{}",
  36. HOST,InetAddress.getLocalHost().getHostName());
  37. return;
  38. }
  39. if(!TaskContant.PROD.equals(active)){
  40. log.info("非正式环境不用删除!");
  41. return;
  42. }
  43. StopWatch stopWatch = new StopWatch();
  44. stopWatch.start();
  45. log.info("删除事项表 所有数据 等待新数据推上来");
  46. if(kqService.remove(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class))){
  47. log.info("删除成功");
  48. }
  49. log.info("当前表里还有数据 :{}条",kqService.count());
  50. stopWatch.stop();
  51. log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds());
  52. }
  53. }