代碼
@Component
@Order(value = 1)
@Log4j2
public class LiftProcessor implements CommandLineRunner{
@Autowired
private ISmartsiteLiftDeviceService deviceService;
@Autowired
private ISmartsiteLiftWorkcycService workcycService;
@Autowired
private ISmartsiteLiftDataService liftDataService;
@Override
public void run(String... args) throws Exception {
log.info(">>>>>>>>>>>>>>>服務啟動執行,執行加載資料等操作<<<<<<<<<<<<<");
MqttLift mqttLift = new MqttLift();
mqttLift.initMqttLift();
while (true) {
deviceService.pushDevice();
workcycService.pushLiftWorkcyc();
liftDataService.pushLiftData();
try {
Thread.sleep(480000);
} catch (InterruptedException e) {
log.error("Lift run error",e);
}
}
}
}