| | |
| | | import com.ruoyi.sy.domain.ArdSyCarRtu; |
| | | import com.ruoyi.sy.mapper.ArdSyCarRtuMapper; |
| | | import com.ruoyi.sy.service.ArdSyCarRtuService; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class MqttOnce implements CommandLineRunner { |
| | | public class MqttOnce{ |
| | | |
| | | @Autowired |
| | | private ArdSyCarRtuService ardSyCarRtuService; |
| | | |
| | | @Override |
| | | public void run(String... args) throws Exception { |
| | | String topic = ardSyCarRtuService.allCarTopic(); |
| | | MqttConsumer mqttConsumer = new MqttConsumer(); |
| | | mqttConsumer.subscribe(topic,2); |
| | | log.info("mqtt订阅清淤车辆锁信息:"+topic); |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | //获取电磁锁地址 |
| | | String mqttUrl = sysConfigService.selectConfigByKey("ElectromagneticLockUrl"); |
| | | List<ArdSyCarRtu> rtus = ardSyCarRtuService.allCarTopic(); |
| | | for (int i = 0; i < rtus.size(); i++) { |
| | | ArdSyCarRtu rtu = rtus.get(i); |
| | | String publish = rtu.getTopicPublish(); |
| | | } |
| | | // MqttConsumer mqttConsumer = new MqttConsumer(); |
| | | // for (int i = 0; i < topic.length; i++) { |
| | | // mqttConsumer.subscribe(topic[i],2); |
| | | // } |
| | | // log.info("mqtt订阅清淤车辆锁信息:"+Arrays.toString(topic)); |
| | | } |
| | | } |