| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.Duration; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public static final String PV = "PV_"; |
| | | public static final String PV = "point_value:"; |
| | | |
| | | public static final int offset = 60 * 3; |
| | | public static final long offset = 60 * 3L; |
| | | |
| | | /** |
| | | * 采集 |
| | |
| | | for (InfluxPointValuePOJO pointValue : pointValues) { |
| | | if (pointValue instanceof InfluxPointValueSimPOJO) { |
| | | InfluxPointValueSimPOJO simPOJO = (InfluxPointValueSimPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + simPOJO.getPoint(), simPOJO.getValue(), offset); |
| | | redisTemplate.opsForValue().set(PV + simPOJO.getPoint(), simPOJO.getValue().doubleValue(), offset, TimeUnit.SECONDS); |
| | | } else if (pointValue instanceof InfluxPointValueDigPOJO) { |
| | | InfluxPointValueDigPOJO digPOJO = (InfluxPointValueDigPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + digPOJO.getPoint(), digPOJO.getValue(), offset); |
| | | redisTemplate.opsForValue().set(PV + digPOJO.getPoint(), digPOJO.getValue().intValue(), offset, TimeUnit.SECONDS); |
| | | } else if (pointValue instanceof InfluxPointValueBoolPOJO) { |
| | | InfluxPointValueBoolPOJO boolPOJO = (InfluxPointValueBoolPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + boolPOJO.getPoint(), boolPOJO.getValue(), offset); |
| | | redisTemplate.opsForValue().set(PV + boolPOJO.getPoint(), boolPOJO.getValue().booleanValue(), offset, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | log.info("更新采集状态"); |