czt
2024-07-13 b030109e665301e7edd6ad0fe5c832ee10fe39b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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();
        }
    }
}