| | |
| | | @Slf4j |
| | | @Component |
| | | public class HttpCollectorForAsdb { |
| | | private static Map<String, HttpApiEntity> apiMap = new HashMap<>(); |
| | | |
| | | @Autowired |
| | | private HttpApiService httpApiService; |
| | |
| | | public static final long offset = 10; |
| | | |
| | | private HttpApiEntity getHttpApi(String id) { |
| | | if (apiMap.containsKey(id)) { |
| | | return apiMap.get(id); |
| | | } |
| | | HttpApiEntity httpApi = httpApiService.info(id); |
| | | apiMap.put(id, httpApi); |
| | | return httpApi; |
| | | return httpApiService.getFromCatch(id); |
| | | } |
| | | |
| | | public BigDecimal getTagValue(String sourceId, String tagNo) { |
| | |
| | | List<HttpAsdbRespDataVO> dataList = JSON.parseArray(responseStr, HttpAsdbRespDataVO.class); |
| | | log.info("存入IailabData缓存: " + catchKey); |
| | | dataList.forEach(item -> { |
| | | redisTemplate.opsForValue().set(catchKey, item.getValue().toString(), offset, TimeUnit.SECONDS); |
| | | redisTemplate.opsForValue().set("IailabData:" + httpApi.getCode() + ":" + item.getPoint(), item.getValue().toString(), offset, TimeUnit.SECONDS); |
| | | }); |
| | | value = Objects.requireNonNull(dataList.stream().filter(data -> tagNo.equals(data.getPoint())).findFirst().orElse(null)).getValue(); |
| | | for (HttpAsdbRespDataVO data : dataList){ |
| | | if (tagNo.equals(data.getPoint())){ |
| | | value = data.getValue(); |
| | | break; |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |