You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. package com.xujie.sys.common.utils;
  2. import com.xujie.sys.modules.pms.service.EamProjectService;
  3. import com.xujie.sys.modules.pms.service.EamService;
  4. import com.xujie.sys.modules.reader.service.GetInformationForExcelService;
  5. import com.xujie.sys.modules.reader.service.ModbusCommunicateService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.scheduling.annotation.EnableScheduling;
  9. import org.springframework.scheduling.annotation.Scheduled;
  10. import org.springframework.stereotype.Component;
  11. import javax.mail.MessagingException;
  12. import java.io.UnsupportedEncodingException;
  13. @Component
  14. @Configuration
  15. @EnableScheduling
  16. public class TaskUtils {
  17. @Autowired
  18. private EamService eamService;
  19. @Autowired
  20. private GetInformationForExcelService getInformationForExcelService;
  21. @Autowired
  22. private EamProjectService eamProjectService;
  23. @Autowired
  24. private ModbusCommunicateService modbusCommunicateService;
  25. // 添加定时任务
  26. @Scheduled(cron = "${task.data.eamWorkPlanTime}") // 每天0点执行
  27. public void doTask() {
  28. eamService.eamWorkPlanTask();
  29. }
  30. /**
  31. * 读取Excel数据
  32. */
  33. @Scheduled(cron = "${task.data.getExcelInformation}" ) //每五秒执行 读取文件数据
  34. public void getExcel(){
  35. getInformationForExcelService.saveByExcel();
  36. }
  37. //添加未上传文件邮件通知定時任務
  38. // @Scheduled(cron = "${task.data.sendEmail}" )
  39. // public void sendEmail() throws MessagingException, UnsupportedEncodingException {
  40. // eamProjectService.sendEmail();
  41. // }
  42. /**
  43. * 读取Modbus数据
  44. */
  45. @Scheduled(cron = "${task.data.modbusCommunicate}")
  46. public void getModbus(){
  47. modbusCommunicateService.getInfoByModbus();
  48. }
  49. }