| | |
| | | * @Date 2021/6/15 13:56 |
| | | * @Version TODO |
| | | **/ |
| | | |
| | | @ServerEndpoint("/singleDevice/{mac}") |
| | | @Component |
| | | @Data |
| | |
| | | |
| | | private Map<String, Object> regionAqi; |
| | | |
| | | private Map<String,Object> adjustFormula; |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, @PathParam("mac") String mac) throws Exception { |
| | | this.session = session; |
| | | this.mac = mac; |
| | | this.deviceAlarmInfo = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | | this.unitConversions = redisTemplate.opsForList().range(RedisConstants.UNIT_CONVERSION, 0, -1); |
| | | this.adjustFormula = redisTemplate.opsForHash().entries("adjust_"+mac); |
| | | //获取设备地区对应的AQI用于补偿使用 |
| | | Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac); |
| | | Map<String, Object> monitorPointMap = (Map<String, Object>) deviceInfo.get("monitorPoint"); |
| | | String areaCode = String.valueOf(monitorPointMap.get("areaCode")); |
| | | String cityCode = String.valueOf(monitorPointMap.get("cityCode")); |
| | | try { |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.CITY_AQI, areaCode); |
| | | if (ObjectUtils.isEmpty(this.regionAqi)) |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | } catch (Exception e) { |