| | |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | /* |
| | | * 从redis获取设备信息 |
| | |
| | | organizationInfo = organizationMapper.selectById(specialDevice.getOrganizationId()); |
| | | specialDeviceInfoDTO.setOrganization(organizationInfo); |
| | | |
| | | System.out.println("========================"); |
| | | System.out.println(specialDeviceInfoDTO); |
| | | return specialDeviceInfoDTO; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> adjustSpecialDeviceData(Map<String, Object> deviceData) { |
| | | String mac = deviceData.remove("mac").toString(); |
| | | //从redis获取校准公式 |
| | | Map<String, Object> adjustFormula = redisTemplate.opsForHash().entries(RedisConstants.ADJUST + "_" + mac); |
| | | if (!org.springframework.util.ObjectUtils.isEmpty(adjustFormula)) { |
| | | SpecialDeviceInfoDTO specialDeviceInfo = getDeviceInfoFromRedis(mac); |
| | | if (org.springframework.util.ObjectUtils.isEmpty(specialDeviceInfo)) { |
| | | QueryWrapper<SpecialDevice> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac", mac).eq("is_delete", Constants.NOT_DELETE); |
| | | SpecialDevice specialDevice = specialDeviceMapper.selectOne(queryWrapper); |
| | | if (specialDevice != null) { |
| | | specialDeviceInfo = selectDeviceInfoDTOById(specialDevice.getId()); |
| | | setDeviceInfoToRedis(mac, specialDeviceInfo); |
| | | } |
| | | } |
| | | //获取设备绑定的国控站信息 |
| | | Map<String, Object> govMpInfo = (Map<String, Object>) specialDeviceInfo.getGovMonitorPoint(); |
| | | Map<String, Object> aqiMap = null; |
| | | if (govMpInfo.get("guid") != null) { |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, govMpInfo.get("guid").toString()); |
| | | } |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, org.springframework.util.ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |
| | | deviceData.remove("DataTime"); |
| | | return deviceData; |
| | | } |
| | | |
| | | private void insertOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | QueryWrapper<OrganizationUnitAlarm> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | | queryOrganizationVersionWrapper.eq("organization_id", orgId); |