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
63 lines
1.8 KiB
package com.xujie.sys.common.utils;
|
|
|
|
|
|
import com.xujie.sys.modules.pms.service.EamProjectService;
|
|
import com.xujie.sys.modules.pms.service.EamService;
|
|
import com.xujie.sys.modules.reader.service.GetInformationForExcelService;
|
|
import com.xujie.sys.modules.reader.service.ModbusCommunicateService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.mail.MessagingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
@Component
|
|
@Configuration
|
|
@EnableScheduling
|
|
public class TaskUtils {
|
|
|
|
@Autowired
|
|
private EamService eamService;
|
|
|
|
@Autowired
|
|
private GetInformationForExcelService getInformationForExcelService;
|
|
|
|
@Autowired
|
|
private EamProjectService eamProjectService;
|
|
|
|
@Autowired
|
|
private ModbusCommunicateService modbusCommunicateService;
|
|
|
|
// 添加定时任务
|
|
@Scheduled(cron = "${task.data.eamWorkPlanTime}") // 每天0点执行
|
|
public void doTask() {
|
|
eamService.eamWorkPlanTask();
|
|
}
|
|
|
|
/**
|
|
* 读取Excel数据
|
|
*/
|
|
@Scheduled(cron = "${task.data.getExcelInformation}" ) //每五秒执行 读取文件数据
|
|
public void getExcel(){
|
|
getInformationForExcelService.saveByExcel();
|
|
}
|
|
|
|
//添加未上传文件邮件通知定時任務
|
|
// @Scheduled(cron = "${task.data.sendEmail}" )
|
|
// public void sendEmail() throws MessagingException, UnsupportedEncodingException {
|
|
// eamProjectService.sendEmail();
|
|
// }
|
|
|
|
/**
|
|
* 读取Modbus数据
|
|
*/
|
|
@Scheduled(cron = "${task.data.modbusCommunicate}")
|
|
public void getModbus(){
|
|
modbusCommunicateService.getInfoByModbus();
|
|
}
|
|
|
|
|
|
}
|