diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java index 3643d04..eea1486 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java @@ -24,10 +24,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -86,10 +83,22 @@ public class IDataLimitRateAsyncImpl implements IDataLimitRateAsync { * 功能描述:获取influxDB -> data_v -> * 总计算次数(用data_v中phasic_type=A,value_type=avg,quality_flag=0来参与统计) */ + //在线监测设备会有AB、BC、CA的数据,会导致数据重复计算,这边根据时间去重 Map> allTime = dataVAllTime.stream() .filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType())) .filter(x -> InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(x.getValueType())) - .collect(Collectors.groupingBy(DataVDto::getLineId)); + .collect(Collectors.groupingBy( + DataVDto::getLineId, + Collectors.collectingAndThen( + Collectors.toCollection( + // 使用 TreeSet 根据时间排序并去重 + () -> new TreeSet<>( + Comparator.comparing(DataVDto::getMinTime) + ) + ), + ArrayList::new + ) + )); /** * 功能描述:获取influxDB -> data_plt ->