| | |
| | | import com.moral.api.service.DeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.moral.api.service.SysDictDataService; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | @Autowired |
| | | private OrganizationService organizationService; |
| | | |
| | | /* |
| | | * 从redis获取设备信息 |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectMonitorsByOrgId(Integer orgId) { |
| | | //获取所有子组织 |
| | | List<Organization> organizations = organizationService.getAllChildrenOrganization(orgId); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(orgId); |
| | | QueryWrapper<MonitorPoint> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("id", "name").eq("organization_id", orgId).eq("is_delete", Constants.NOT_DELETE); |
| | | queryWrapper.select("id", "name") |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .in("organization_id", orgIds); |
| | | return monitorPointMapper.selectMaps(queryWrapper); |
| | | } |
| | | |
| | |
| | | Object orgId = parameters.get("organizationId"); |
| | | Object mpId = parameters.get("monitorPointId"); |
| | | |
| | | //查询某组织下所有设备 |
| | | //查询某组织下所有设备,包括子组织 |
| | | if (orgId != null) { |
| | | queryWrapper.eq("organization_id", orgId); |
| | | //查询所有子组织 |
| | | List<Organization> organizations = organizationService.getAllChildrenOrganization(Integer.parseInt(orgId.toString())); |
| | | List<Integer> orgIds = organizations.stream().map(Organization::getId).collect(Collectors.toList()); |
| | | orgIds.add(Integer.parseInt(orgId.toString())); |
| | | queryWrapper.in("organization_id", orgIds); |
| | | } |
| | | |
| | | //查询某站点下所有设备 |
| | |
| | | Map<String, Object> govMpInfo = (Map<String, Object>) deviceInfo.get("govMonitorPoint"); |
| | | Map<String, Object> aqiMap = null; |
| | | if (govMpInfo.get("guid") != null) { |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, govMpInfo.get("guid").toString()); |
| | | aqiMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, govMpInfo.get("guid").toString()); |
| | | } |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |