| | |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | //@Component |
| | | @Component |
| | | @Slf4j |
| | | public class KafkaConsumer { |
| | | |
| | |
| | | String key = next.getKey(); |
| | | Object value = next.getValue(); |
| | | if (key.contains("-Avg")) { |
| | | newMap.put(key.replaceAll("-Avg", ""), value); |
| | | newMap.put(key.replaceAll("-Avg", ""), Double.parseDouble(value.toString())); |
| | | } else { |
| | | newMap.put(key, value); |
| | | } |
| | |
| | | String key = next.getKey(); |
| | | Object value = next.getValue(); |
| | | if (key.contains("-Avg")) { |
| | | newMap.put(key.replaceAll("-Avg", ""), value); |
| | | newMap.put(key.replaceAll("-Avg", ""), Double.parseDouble(value.toString())); |
| | | } else { |
| | | newMap.put(key, value); |
| | | } |
| | |
| | | //数据校准 |
| | | data = deviceService.adjustDeviceData(data); |
| | | //存入redis |
| | | redisTemplate.opsForHash().put(RedisConstants.DEVICE_DATA, mac, data); |
| | | redisTemplate.opsForHash().put(RedisConstants.DATA_SECOND, mac, data); |
| | | //判断并修改设备状态 |
| | | deviceService.judgeDeviceState(data); |
| | | ack.acknowledge(); |