| | |
| | | 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; |
| | |
| | | @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; |
| | |
| | | |
| | | 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"); |
| | | //获取登录日志 |
| | |
| | | } |
| | | |
| | | //推送电每月 |
| | | // @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<>(); |