| | |
| | | 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"); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断组织是否含有该设备的型号,如果没有则添加到组织型号关系表中 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | * @Description: 判断组织是否含有该设备的型号,如果没有则添加到组织型号关系表中 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | private void insertOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | //查询是否含有该型号 |
| | | QueryWrapper<OrganizationUnitAlarm> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | |
| | | String sensorCode = versionSensorUnit.getSensorCode(); |
| | | //设置默认报警值 |
| | | SysDictData alarm = sensorAlarms.get(sensorCode); |
| | | if(alarm!=null) |
| | | if (alarm != null) |
| | | organizationUnitAlarm.setAlarmLevel(alarm.getDataValue()); |
| | | organizationUnitAlarm.setOrganizationId(orgId); |
| | | organizationUnitAlarm.setVersionId(versionId); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 删除设备后,如果该组织没有这个设备型号其他的设备了,则删除组织型号关系表中该型号的信息。 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | * @Description: 删除设备后,如果该组织没有这个设备型号其他的设备了,则删除组织型号关系表中该型号的信息。 |
| | | * @Param: [orgId, versionId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/6 |
| | | */ |
| | | private void deleteOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | QueryWrapper<Device> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | | queryOrganizationVersionWrapper.eq("organization_id", orgId); |