O
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.
 
 
 
 
 
 

138 lines
3.6 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.pms.service.Impl.QcServiceImpl;
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.beans.factory.annotation.Value;
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 QcServiceImpl qcService;
@Autowired
private GetInformationForExcelService getInformationForExcelService;
@Autowired
private EamProjectService eamProjectService;
@Autowired
private ModbusCommunicateService modbusCommunicateService;
// 全局任务开关
@Value("${task.enabled:true}")
private boolean taskEnabled;
/**
* 添加定时任务
*/
@Scheduled(cron = "${task.data.eamWorkPlanTime}")
public void doTask() {
if(!taskEnabled){
return;
}
eamService.eamWorkPlanTask();
}
/**
* 读取Excel数据
*/
@Scheduled(cron = "${task.data.getExcelInformation}" ) //每五秒执行 读取文件数据
public void getExcel(){
if(!taskEnabled){
return;
}
getInformationForExcelService.saveByExcel();
}
/**
* 添加未上传文件邮件通知定時任務
*/
@Scheduled(cron = "${task.data.sendEmail}" )
public void sendEmail() throws MessagingException, UnsupportedEncodingException {
if(!taskEnabled){
return;
}
eamProjectService.sendEmail();
}
/**
* 读取Modbus数据
*/
@Scheduled(cron = "${task.data.modbusCommunicate}")
public void getModbus(){
if(!taskEnabled){
return;
}
modbusCommunicateService.getInfoByModbus();
}
@Scheduled(cron = "${task.data.readPerSecond}")
public void readPerSecond(){
if(!taskEnabled){
return;
}
modbusCommunicateService.readPerSecond();
}
@Scheduled(cron = "${loraurl.getLoraWatchTime}")
//@Scheduled(cron = "0/30 * * * * ?")
public void getLoraWatchMessage(){
if(!taskEnabled){
return;
}
eamService.getLoraWatch();};
//@Scheduled(cron = "${loraurl.sendLoraWatchTime}")
public void sendLoraWatchMessage(){
if(!taskEnabled){
return;
}
eamService.sendLoraWatch();};
//@Scheduled(cron = "${loraurl.sendThreeColourTime}")
public void sendThreeColourLight(){
if(!taskEnabled){
return;
}
eamService.sendThreeColourLight();};
@Scheduled(cron = "${loraurl.sendRedColourTime}")
//@Scheduled(cron = "0/10 * * * * ?")
public void sendLoraRedLight(){
if(!taskEnabled){
return;
}
eamService.sendLoraRedLight();}
/**
* 创建质量任务
*/
@Scheduled(cron = "${task.data.createQCInspection}")
public void createQCInspection() {
if(!taskEnabled){
return;
}
qcService.createQCInspection();
}
}