package com.ld.igds.timer;
|
|
import com.bstek.bdf2.core.model.DefaultCompany;
|
import com.ld.igds.common.CoreCommonService;
|
import com.ld.igds.view.manager.TempManager;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
/**
|
* 基础模块标准定时器业务配置
|
*/
|
@Slf4j
|
@Component(ScheduledBasic.BEAN_ID)
|
public class ScheduledBasic {
|
|
public static final String BEAN_ID = "basic.scheduled";
|
|
@Resource
|
private TempManager thManager;
|
@Resource
|
private CoreCommonService coreCommonService;
|
|
@Resource
|
private WeatherTimerService weatherTimerService;
|
|
|
/**
|
* 每间隔30分钟执行一次
|
*/
|
@Scheduled(cron = "0 0/30 * * * ?")
|
public void scheduled30() {
|
|
//定时获取分机的温湿度检测结果
|
doExeTh();
|
|
//定时获取气象信息
|
weatherTimerService.doExe();
|
}
|
|
/**
|
* 定时获取分机的温湿度检测结果
|
*/
|
private void doExeTh() {
|
List<DefaultCompany> list = coreCommonService.getCompanyList();
|
if (null == list || list.isEmpty()) return;
|
|
try {
|
for (DefaultCompany company : list) {
|
log.info("===================系统定时获取分机下的温湿度信息-{}=======================", company.getId());
|
thManager.scheduledCheck(company.getId());
|
|
Thread.sleep(500);
|
}
|
} catch (Exception e) {
|
e.getStackTrace();
|
}
|
}
|
}
|