| | |
| | | package com.moral.api.websocket; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import lombok.Data; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.moral.api.entity.UnitConversion; |
| | | import com.moral.api.pojo.redisBean.SpecialDeviceInfoDTO; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | //走航车实时websocket |
| | |
| | | |
| | | private String mac; |
| | | |
| | | private SpecialDevice deviceAlarmInfo; |
| | | |
| | | private Map<String, Object> adjustFormula; |
| | | |
| | | private SpecialDevice specialDevice; |
| | | |
| | | private Map<String, Object> regionAqi; |
| | |
| | | public void onOpen(Session session, @PathParam("mac") String mac) { |
| | | this.session = session; |
| | | this.mac = mac; |
| | | this.deviceAlarmInfo = (SpecialDevice) redisTemplate.opsForHash().get(RedisConstants.SPECIAL_DEVICE_INFO, mac); |
| | | this.unitConversions = redisTemplate.opsForList().range(RedisConstants.UNIT_CONVERSION, 0, -1); |
| | | this.adjustFormula = redisTemplate.opsForHash().entries("adjust_"+mac); |
| | | this.specialDevice = (SpecialDevice) redisTemplate.opsForHash().get(RedisConstants.SPECIAL_DEVICE_INFO, mac); |
| | | //获取设备地区对应的AQI用于补偿使用 |
| | | /*Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) deviceInfo.get("organization"); |
| | | String areaCode = String.valueOf(orgInfo.get("areaCode")); |
| | | String cityCode = String.valueOf(orgInfo.get("cityCode")); |
| | | try { |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | if (ObjectUtils.isEmpty(this.regionAqi)) |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | //获取设备信息 |
| | | SpecialDeviceInfoDTO deviceInfo = (SpecialDeviceInfoDTO) redisTemplate.opsForHash().get(RedisConstants.SPECIAL_DEVICE, mac); |
| | | //获取与设备绑定的国控站guid, |
| | | String guid = deviceInfo.getSpecialDevice().getGuid(); |
| | | if (!ObjectUtils.isEmpty(guid)) { |
| | | //获取国控aqi数据,用于补偿 |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, guid); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | }*/ |
| | | } |
| | | sockets.add(this); |
| | | } |
| | | |