package com.cec.plugins.service.task; import com.cec.plugins.domain.reported.DeviceDto; import com.cec.plugins.enumerate.DeviceEnum; import com.cec.plugins.service.RedisClientSource; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @author zhanghaijun * @date 2023/11/28 22:07 * @description [一句话描述该类的功能] */ @Slf4j @Component @RequiredArgsConstructor public class DeviceScheduleService { private final RedisClientSource redisClientSource; private final ReportService reportService; @Async @Scheduled(fixedDelayString = "${project.platform.fixed-delay}") public void heartbeat() { DeviceDto dto = new DeviceDto(); for (DeviceEnum deviceEnum : DeviceEnum.values()) { dto.addDevice(deviceEnum.getUuid(), redisClientSource.getCacheStr(deviceEnum.getKey())); } reportService.reportPlatform("/data/api/v1/deviceState", dto); } }