| | |
| | | import com.rabbitmq.client.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.websocket.*; |
| | |
| | | //先放名称地址,用于排序 |
| | | sortMap.put("name", device.getName()); |
| | | sortMap.put("address", device.getAddress()); |
| | | //将传感器代号转化为汉字 |
| | | sortMap.putAll(param); |
| | | //拼接单位 |
| | | param.forEach((key, value) -> { |
| | | Sensor sensor = sensors.get(key); |
| | | if (!ObjectUtils.isEmpty(sensor)) { |
| | | String unit = ObjectUtils.isEmpty(sensor.getUnit()) ? "" : (String) sensor.getUnit(); |
| | | sortMap.put(sensor.getSensorKey(), value + unit); |
| | | } |
| | | }); |
| | | sendMessage(JSON.toJSONString(sortMap)); |
| | | } catch (IOException e) { |
| | | log.error("根据mac发送设备数据异常"); |