ReagentConsumableScheduledTask.java 964 B

1234567891011121314151617181920212223242526
  1. package com.jyxt.thridparty.scheduled;
  2. import com.jyxt.thridparty.service.ReagentConsumableService;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.scheduling.annotation.Scheduled;
  6. import org.springframework.stereotype.Component;
  7. import java.time.LocalDate;
  8. import java.time.format.DateTimeFormatter;
  9. @Component
  10. public class ReagentConsumableScheduledTask {
  11. @Autowired
  12. private ReagentConsumableService reagentConsumableService;
  13. @Scheduled(cron = "${scheduled.reagent-consumable.cron}")
  14. public void startTask() {
  15. LocalDate today = LocalDate.now();
  16. String startTime = today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00";
  17. String endTime = today.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00";
  18. reagentConsumableService.startTask(startTime, endTime);
  19. }
  20. }