2026-08-27 05626a9f0f93a042477e8bb53fe5660e5d18b134
ruoyi-admin/src/main/java/com/ruoyi/web/core/api/ScheduledApi.java
@@ -10,6 +10,9 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
@@ -23,6 +26,15 @@
@Slf4j
//榆林市工业和信息化局数据推送(定时任务)
public class ScheduledApi {
    @Value("${api.loggingEnabled:false}")
    private boolean loggingEnabled;
    @Value("${api.electricityEnabled:false}")
    private boolean electricityEnabled;
    @Value("${api.ip}")
    private String apiIp;
    @Value("${api.entName}")
    private String entName;
@@ -48,9 +60,19 @@
    private static final Random RANDOM = new Random();
    @EventListener(ApplicationReadyEvent.class)
    public void logPushStatus() {
        log.info("榆林市工业和信息化局数据推送配置:登录日志推送{},电量数据推送{},推送地址:{},企业:{}",
                loggingEnabled ? "已开启" : "已关闭",
                electricityEnabled ? "已开启" : "已关闭", apiIp, entName);
    }
    //推送登录日志每周
//    @Scheduled(cron = "0 0 1 ? * 1")
    @Scheduled(cron = "0 0 1 ? * 1")
    public void logging(){
        if (!loggingEnabled) {
            return;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取登录日志
@@ -80,8 +102,11 @@
    }
    //推送电每月
//    @Scheduled(cron = "0 0 1 1 * ?")
    @Scheduled(cron = "0 0 1 1 * ?")
    public void electricity(){
        if (!electricityEnabled) {
            return;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:dd");
        //获取登录日志
        List<ElectricityDto> electricityDtos = new ArrayList<>();