| | |
| | | import com.moral.api.service.DeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.moral.api.service.GovMonitorPointService; |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | |
| | | mpInfo.put("provinceCode", monitorPoint.getProvinceCode()); |
| | | deviceInfo.put("monitorPoint", mpInfo); |
| | | |
| | | //国控站点 |
| | | Map<String, Object> govMpInfo = new LinkedHashMap<>(); |
| | | |
| | | govMpInfo.put("guid", null); |
| | | govMpInfo.put("name", null); |
| | | if (device.getGovMonitorPoint() != null) { |
| | | govMpInfo.put("guid", device.getGovMonitorPoint().getGuid()); |
| | | govMpInfo.put("name", device.getGovMonitorPoint().getName()); |
| | | } |
| | | deviceInfo.put("govMonitorPoint", govMpInfo); |
| | | setDeviceInfoToRedis(mac, deviceInfo); |
| | | return deviceInfo; |
| | | } |
| | |
| | | Map<String, Object> adjustFormula = redisTemplate.opsForHash().entries(RedisConstants.ADJUST + "_" + mac); |
| | | if (!ObjectUtils.isEmpty(adjustFormula)) { |
| | | Map<String, Object> deviceInfo = getDeviceByMac(mac); |
| | | Map<String, Object> monitorPoint = (Map<String, Object>) deviceInfo.get("monitorPoint"); |
| | | String areaCode = monitorPoint.get("areaCode").toString(); |
| | | String cityCode = monitorPoint.get("cityCode").toString(); |
| | | |
| | | Map<String, Object> aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | if (ObjectUtils.isEmpty(aqiMap)) { |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | //没有绑定国控站,不校准 |
| | | Map<String, Object> govMpInfo = (Map) deviceInfo.get("govMonitorPoint"); |
| | | if (ObjectUtils.isEmpty(govMpInfo.get("guid"))) { |
| | | return deviceData; |
| | | } |
| | | String guid = (String) govMpInfo.get("guid"); |
| | | //获取国控站aqi数据 |
| | | Map<String, Object> aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, guid); |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |
| | | deviceData.remove("DataTime"); |