| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * 计算点处理 |
| | |
| | | log.info(JSON.toJSONString(listBad)); |
| | | dtos.forEach(dto -> { |
| | | try { |
| | | Object value = singleCompute(dto, dataMap, listGood, listBad); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); |
| | | Object rawValue = singleCompute(dto, dataMap, listGood, listBad); |
| | | BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); |
| | | BigDecimal calValue = new BigDecimal(rawValue.toString()).multiply(coefficient); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, calValue); |
| | | pojo.setTimestamp(collectTime.toInstant()); |
| | | result.add(pojo); |
| | | } catch (Exception ex) { |
| | |
| | | String expression = dto.getExpression(); |
| | | log.info("PointNo=" + dto.getPointNo() + ";SourceExpression=" + expression); |
| | | String[] arr = expression.split(regex); |
| | | // 去掉arr中的空格 |
| | | arr = Stream.of(arr).filter(StringUtils::isNotBlank).toArray(String[]::new); |
| | | // 判断arr都在dataMap中包含 |
| | | if (!Arrays.stream(arr).allMatch(dataMap::containsKey)) { |
| | | log.info("dataMap not contains key"); |
| | |
| | | if (redisTemplate.hasKey(PointCollector.PV + item.getPointNo())) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item); |
| | | Object rawValue = singleCompute(item); |
| | | BigDecimal coefficient = item.getUnittransfactor() == null ? BigDecimal.ONE : item.getUnittransfactor(); |
| | | value = new BigDecimal(rawValue.toString()).multiply(coefficient); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |