| | |
| | | import com.moral.api.entity.UnitConversion; |
| | | import com.moral.api.websocket.SingleDeviceServer; |
| | | import com.moral.util.UnitConvertUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.kafka.clients.consumer.Consumer; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | | import org.apache.kafka.common.TopicPartition; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.kafka.annotation.KafkaListener; |
| | | import org.springframework.kafka.listener.ConsumerSeekAware; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Component |
| | | public class SecondDataConsumer implements ConsumerSeekAware { |
| | | |
| | | @KafkaListener(topics = "second_data", groupId = "SecondsDataGroup996") |
| | | @KafkaListener(containerFactory = "secondDataListenerFactory",topics = "second_data") |
| | | public void listen(ConsumerRecord<String, String> record, Consumer consumer) throws Exception { |
| | | String messageStr = record.value(); |
| | | Map<String, Object> message = (Map<String, Object>) JSON.parse(messageStr); |
| | |
| | | resultMessgae.put(sensor.getCode(), resultData); |
| | | } else { |
| | | //拼接单位 |
| | | sourceData += showUnit; |
| | | sourceData = sourceData + " " + showUnit; |
| | | resultMessgae.put(sensor.getCode(), sourceData); |
| | | } |
| | | } |