doum
2026-05-25 74190ebc24e6e850d418ad0ce041fd91b795c23e
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
package com.doumee.job;
 
import com.doumee.service.business.YwElectricalBizService;
import com.doumee.service.business.YwElectricalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
@Slf4j
@Component
public class ElectricalScheduleJob {
 
    @Autowired
    private YwElectricalService ywElectricalService;
    @Autowired
    private YwElectricalBizService ywElectricalBizService;
 
    /** 每5分钟同步采集器在线状态 */
    @Scheduled(cron = "0 */5 * * * ?")
    public void syncElectricalStatus() {
        try {
            ywElectricalService.getElectricalStatus();
        } catch (Exception e) {
            log.error("syncElectricalStatus failed", e);
        }
    }
 
    /** 每小时0分30秒批量抄表 */
    @Scheduled(cron = "30 0 * * * ?")
    public void syncMeterData() {
        try {
            ywElectricalBizService.syncMeterDataScheduled();
        } catch (Exception e) {
            log.error("syncMeterData failed", e);
        }
    }
 
    /** 每日清理3个月前的接口日志 */
    @Scheduled(cron = "0 30 2 * * ?")
    public void cleanElectricalLog() {
        try {
            ywElectricalBizService.cleanLogBeforeThreeMonths();
        } catch (Exception e) {
            log.error("cleanElectricalLog failed", e);
        }
    }
}