yangjunfeng 1 year ago
parent
commit
0cffb13c5b

+ 2 - 7
snws-gps/snws-gps-boot/src/main/resources/mapper/fill/FillMonthMapper.xml

@@ -176,13 +176,8 @@
     <select id="getIndexValDay" resultType="com.tofly.pojo.fill.FillVo">
         select  CONVERT(VARCHAR(100), a.RECORD_TIME, 20) RECORD_TIME,
                 a.BELONG_STATION_ID BELONG_STATION_ID,
-                (select g.DEPT_ID
-                from tf_dept_sewage g
-                where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_id,
-                (select a.NAME
-                from tf_smpn_department_x g
-                left join tf_dept_sewage h on g.ID = h.DEPT_ID
-                where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_name,
+                (select g.DEPT_ID from tf_dept_sewage g where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_id,
+                (select h.NAME from tf_smpn_department_x h left join tf_dept_sewage g on h.ID = g.DEPT_ID where g.SEWAGE_STATION_ID = a.BELONG_STATION_ID) belong_dept_name,
                 f.name sewage_station_name,
                 ISNULL(a.ELECTRO, 0) ELECTRO,
                 ISNULL(b.DAY_SLUDGE_DEHYDRATION, 0) DAY_SLUDGE_DEHYDRATION,

+ 0 - 1
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/config/ScheduledTask.java

@@ -6,7 +6,6 @@ import com.tofly.monitor.handler.device.DayStatisticsHandler;
 import com.tofly.monitor.handler.device.DeviceStatusHandler;
 import com.tofly.monitor.handler.device.HistoryToRealTimeHandler;
 import com.tofly.monitor.handler.device.ScadaHandler;
-import com.tofly.monitor.screenDisplay.service.ScadaLjFlowService;
 import com.tofly.monitor.util.DateTimeUtil;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;

+ 0 - 1
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/handler/device/HistoryToRealTimeHandler.java

@@ -8,7 +8,6 @@ import com.tofly.monitor.mqtt.SnowFlake;
 import com.tofly.monitor.screenDisplay.entity.ScadaLjFlow;
 import com.tofly.monitor.screenDisplay.entity.dto.WisdomDisplayDto;
 import com.tofly.monitor.screenDisplay.mapper.CustomDisplayMapper;
-import com.tofly.monitor.screenDisplay.service.ScadaLjFlowService;
 import com.tofly.pojo.IndexVal;
 import com.tofly.pojo.vo.StationIndexVo;
 import lombok.AllArgsConstructor;

+ 11 - 43
snws-monitor/snws-monitor-boot/src/main/java/com/tofly/monitor/handler/device/ScadaHandler.java

@@ -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)) {