|
@@ -5,14 +5,12 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.tofly.monitor.common.FlowConstant;
|
|
|
-import com.tofly.monitor.em.IndexTypeTimeWaveEnum;
|
|
|
import com.tofly.monitor.mapper.TfYwpnMonitorIndexWMapper;
|
|
|
import com.tofly.monitor.mqtt.SnowFlake;
|
|
|
import com.tofly.monitor.screenDisplay.entity.ScadaLjFlow;
|
|
|
import com.tofly.monitor.screenDisplay.entity.StatisticsScada;
|
|
|
import com.tofly.monitor.screenDisplay.entity.dto.WisdomDisplayDto;
|
|
|
import com.tofly.monitor.screenDisplay.mapper.CustomDisplayMapper;
|
|
|
-import com.tofly.monitor.screenDisplay.mapper.StatisticsScadaMapper;
|
|
|
import com.tofly.monitor.screenDisplay.service.ScadaLjFlowService;
|
|
|
import com.tofly.monitor.screenDisplay.service.StatisticsScadaService;
|
|
|
import com.tofly.monitor.service.IndicateParaService;
|
|
@@ -22,8 +20,6 @@ import com.tofly.pojo.vo.StationIndexVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -31,7 +27,9 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.*;
|
|
|
+import java.util.concurrent.ArrayBlockingQueue;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -250,47 +248,19 @@ public class ScadaHandler {
|
|
|
|
|
|
wisdomDisplayDto.setTableName("tf_ywpn_monitor_history_r");
|
|
|
List<StationIndexVo> stationIndexVos = customDisplayMapper.viewStationIndex(wisdomDisplayDto);
|
|
|
- List<ScadaLjFlow> scadaLjFlowList = scadaLjFlowService.list(new QueryWrapper<ScadaLjFlow>().lambda()
|
|
|
- .between(ScadaLjFlow::getScadaTime, startDate, endDate)
|
|
|
- .orderByDesc(ScadaLjFlow::getScadaTime));
|
|
|
- if(CollUtil.isEmpty(stationIndexVos) && CollUtil.isEmpty(scadaLjFlowList)) {
|
|
|
+ if(CollUtil.isEmpty(stationIndexVos)) {
|
|
|
return;
|
|
|
}
|
|
|
List<IndicatePara> indicateParaList = indicateParaService.list();
|
|
|
codes.forEach(code -> {
|
|
|
- List<Double> indexValList;
|
|
|
- String value;
|
|
|
- Long indexType = code.getIndexType();
|
|
|
- if (Objects.equals(indexType, IndexTypeTimeWaveEnum.CUMULATIVE_FLOW.getIndexTypeId())
|
|
|
- || Objects.equals(indexType, IndexTypeTimeWaveEnum.ENERGY.getIndexTypeId())) {
|
|
|
- List<ScadaLjFlow> stationIndexVosFinal = scadaLjFlowList.stream()
|
|
|
- .filter(e -> e.getCode().equals(code.getCode()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollUtil.isEmpty(stationIndexVosFinal)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- value = String.valueOf(stationIndexVosFinal.get(stationIndexVosFinal.size() - 1).getDifferenceValue());
|
|
|
- indexValList = stationIndexVosFinal.stream()
|
|
|
- .map(ScadaLjFlow::getDifferenceValue)
|
|
|
- .filter(e -> e != 0)
|
|
|
- .collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- List<StationIndexVo> stationIndexVosFinal = stationIndexVos.stream()
|
|
|
- .filter(e -> e.getIndexCode().equals(code.getCode()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollUtil.isEmpty(stationIndexVosFinal)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- value = stationIndexVosFinal.get(stationIndexVosFinal.size() - 1).getItVal();
|
|
|
- indexValList = stationIndexVosFinal.stream()
|
|
|
- .map(e -> Double.parseDouble(e.getItVal()))
|
|
|
- .filter(e -> e != 0)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<StationIndexVo> stationIndexVosFinal = stationIndexVos.stream().filter(e -> e.getIndexCode().equals(code.getCode())).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(stationIndexVosFinal)) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ List<Double> indexValList = stationIndexVosFinal.stream().map(e -> Double.parseDouble(e.getItVal())).filter(e -> e != 0).collect(Collectors.toList());
|
|
|
if (CollUtil.isEmpty(indexValList)) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
Double minVal = Collections.min(indexValList);
|
|
|
|
|
@@ -299,13 +269,12 @@ public class ScadaHandler {
|
|
|
double average = indexValList.stream().mapToDouble(Double::valueOf).average().getAsDouble();
|
|
|
|
|
|
double sum = indexValList.stream().mapToDouble(Double::valueOf).sum();
|
|
|
-
|
|
|
|
|
|
int complianceNum = 0;
|
|
|
BigDecimal totalNum = BigDecimal.valueOf(indexValList.size());
|
|
|
for (Double indexVal : indexValList) {
|
|
|
List<IndicatePara> reportList = indicateParaList.stream()
|
|
|
- .filter(e -> Objects.equals(e.getIndexType(), indexType)
|
|
|
+ .filter(e -> Objects.equals(e.getIndexType(), code.getIndexType())
|
|
|
&& indexVal.compareTo(e.getLower()) >= 0
|
|
|
&& indexVal.compareTo(e.getUpper()) <= 0)
|
|
|
.collect(Collectors.toList());
|
|
@@ -318,7 +287,7 @@ public class ScadaHandler {
|
|
|
StatisticsScada statisticsScada = new StatisticsScada();
|
|
|
statisticsScada.setId(SnowFlake.nextId());
|
|
|
statisticsScada.setCode(code.getCode());
|
|
|
- statisticsScada.setValue(value);
|
|
|
+ statisticsScada.setValue(stationIndexVosFinal.get(0).getItVal());
|
|
|
statisticsScada.setAve(Double.toString(average));
|
|
|
statisticsScada.setMax(maxVal.toString());
|
|
|
statisticsScada.setMin(minVal.toString());
|
|
@@ -327,8 +296,7 @@ public class ScadaHandler {
|
|
|
statisticsScada.setStartTime(startDate);
|
|
|
statisticsScada.setEndTime(endDate);
|
|
|
statisticsScada.setStatisticsType(dateType);
|
|
|
-
|
|
|
- statisticsScada.setDataType(String.valueOf(indexType));
|
|
|
+ statisticsScada.setDataType(String.valueOf(code.getIndexType()));
|
|
|
statisticsScadaList.add(statisticsScada);
|
|
|
});
|
|
|
if (CollUtil.isNotEmpty(statisticsScadaList)) {
|