Ver código fonte

pdf、数据统计时间 修改

hxf 1 ano atrás
pai
commit
7efa5f6880

+ 32 - 23
neim-biz/src/main/java/com/jiayue/biz/service/impl/PdfServiceImpl.java

@@ -1,14 +1,12 @@
 package com.jiayue.biz.service.impl;
 
 import cn.hutool.core.date.DateTime;
+import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jiayue.biz.domain.*;
 import com.jiayue.biz.eunms.WindDirectionEnum;
 import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
-import com.jiayue.biz.service.EquipmentAttributeService;
-import com.jiayue.biz.service.PdfService;
-import com.jiayue.biz.service.RealTimeDisplayService;
-import com.jiayue.biz.service.WindTowerDataParentTableService;
+import com.jiayue.biz.service.*;
 import com.jiayue.biz.util.CalculationUtil;
 import com.jiayue.biz.util.DateMomentUtil;
 import com.jiayue.biz.util.DateTimeUtil;
@@ -20,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -44,8 +43,10 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
     private final RealTimeDisplayService realTimeDisplayService;
 
     private final WindDirectionStatisticsDataServiceImpl windDirectionStatisticsDataService;
-    private final WindTowerDataParentTableService windTowerDataParentTableService;
 
+    private final ProphaseAnemometryDataService prophaseAnemometryDataService;
+
+    private final ProphaseWeatherDataService prophaseWeatherDataService;
 
 
     @Override
@@ -71,10 +72,13 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
         List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentId)).collect(Collectors.toList());
 //        List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
         //计算完整性
-        List<Map<String, Object>> maps = windTowerDataParentTableService.countDataIntegrity(equipmentId, sdfTime.format(startDay), sdfTime.format(endDay));
-        for (Map<String, Object> map1 : maps) {
-            realityCount += (long) map1.get("num");
+        List<Entity> entities = prophaseWeatherDataService.selectCount(equipmentId);
+
+        for (Entity entity : entities) {
+            // td engine 取出的时间需要截取字段
+            realityCount += (long) entity.get("count(*)");
         }
+
         //测风塔信息概要
         Map<String, Object> windTowerInfo = getWindTowerInfo(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, height, realityCount, startDay, endDay);
         map.put("windTowerInfo", windTowerInfo);
@@ -148,8 +152,12 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             //如果查询月份等于当前时间月份就拿数据库最后一天数据的时间作为结束时间
             if (endDay.getMonth() == new Date().getMonth()) {
-                WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfos.get(0).getEquipmentNo());
-                endDay = lastData.getTime();
+                List<Entity> lastData = prophaseWeatherDataService.getLastData(windTowerInfos.get(0).getEquipmentNo());
+                Timestamp timestamp = new Timestamp(new Date().getTime());
+                if (lastData != null && lastData.size() > 0) {
+                    timestamp = (Timestamp) lastData.get(0).get("last (ts)");
+                }
+                endDay = new Date(timestamp.getTime());
             }
             Date dayLastTime = DateTimeUtil.getDayLastTime(endDay.getTime());
             long count = (dayLastTime.getTime() + 1000 - startDay.getTime()) / (86400000);
@@ -206,8 +214,12 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
             List<Map<String, Object>> dataList = new ArrayList<>();
             //如果查询月份等于当前时间月份就拿数据库最后一天数据的时间作为结束时间
             if (endDay.getMonth() == new Date().getMonth()) {
-                WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfos.get(0).getEquipmentNo());
-                endDay = lastData.getTime();
+                List<Entity> lastData = prophaseWeatherDataService.getLastData(windTowerInfos.get(0).getEquipmentNo());
+                Timestamp timestamp = new Timestamp(new Date().getTime());
+                if (lastData != null && lastData.size() > 0) {
+                    timestamp = (Timestamp) lastData.get(0).get("last (ts)");
+                }
+                endDay = new Date(timestamp.getTime());
             }
             Date dayLastTime = DateTimeUtil.getDayLastTime(endDay.getTime());
             long count = (dayLastTime.getTime() + 1000 - startDay.getTime()) / (86400000);
@@ -368,9 +380,8 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
         for (WindTowerInfo windTowerInfo : windTowerInfoList) {
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             HashMap<String, Object> hashMap = new HashMap<>();
-            WindTowerDataParentTable firstData = windTowerDataParentTableService.getFirstData(windTowerInfo.getEquipmentNo());
-            WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
-            hashMap.put("time", sdf.format(firstData.getTime()) + " - " + sdf.format(lastData.getTime()));
+            Map<String, Long> startAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(windTowerInfo.getEquipmentNo());
+            hashMap.put("time", sdf.format(new Date(startAndEnd.get("startTime"))) + " - " + sdf.format(new Date(startAndEnd.get("endTime"))));
             hashMap.put("eqId", windTowerInfo.getEquipmentNo());
             timeList.add(hashMap);
         }
@@ -389,21 +400,19 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
         ArrayList<Map<String, Object>> timeList = new ArrayList<>();
         for (WindTowerInfo windTowerInfo : collect) {
             HashMap<String, Object> hashMap = new HashMap<>();
-            WindTowerDataParentTable firstData = windTowerDataParentTableService.getFirstData(windTowerInfo.getEquipmentNo());
-            WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
-
+            Map<String, Long> startAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(windTowerInfo.getEquipmentNo());
             //获取去年数据截止的时间
-            Date yearDay = DateTimeUtil.getYearDay(lastData.getTime().getTime());
+            Date yearDay = DateTimeUtil.getYearDay(startAndEnd.get("endTime"));
             Date startTime;
 
-            if (firstData.getTime().getTime() < yearDay.getTime()) {
+            if (startAndEnd.get("startTime") < yearDay.getTime()) {
                 startTime = DateUtil.offsetMonth(yearDay, 1);
             } else {
-                startTime = firstData.getTime();
+                startTime = new Date(startAndEnd.get("startTime"));
             }
 
             hashMap.put("startTime", startTime);
-            hashMap.put("endTime", lastData.getTime());
+            hashMap.put("endTime", new Date(startAndEnd.get("endTime")));
             hashMap.put("eqId", windTowerInfo.getEquipmentNo());
             timeList.add(hashMap);
         }
@@ -1416,7 +1425,7 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
             BigDecimal aveYearTurInsity = new BigDecimal(0);
             //过滤为0的数据
             List<BigDecimal> collect = yearResults.stream().filter(w -> w.compareTo(new BigDecimal(0)) != 0).collect(Collectors.toList());
-            if(collect.size() > 0){
+            if (collect.size() > 0) {
                 aveYearTurInsity = collect.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(collect.size()), 2, RoundingMode.HALF_UP);
             }
             map.put("yearTurInsity", yearResults);

+ 3 - 3
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseAnemometryDataServiceImpl.java

@@ -49,12 +49,12 @@ public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemo
 
     //查询所有数据
     public List<ProphaseAnemometryData> selectAll(String equipmentId, Timestamp startTime, Timestamp endTime) {
-        return baseMapper.selectAll(equipmentId, startTime, endTime);
+        return this.filterData(baseMapper.selectAll(equipmentId, startTime, endTime));
     }
 
     //所有层高风速风向平均值
     public List<ProphaseAnemometryData> selectAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
-        return baseMapper.selectAve(equipmentId, startTime, endTime);
+        return this.filterData(baseMapper.selectAve(equipmentId, startTime, endTime));
     }
 
     //查询所有层高风速以及风速标差
@@ -91,7 +91,7 @@ public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemo
     //过滤
     public List<ProphaseAnemometryData> filterData(List<ProphaseAnemometryData> prophaseAnemometryData) {
 
-        return prophaseAnemometryData.stream().filter(p -> p.getWsAve() != null && p.getWsAve() < 50).collect(Collectors.toList());
+        return prophaseAnemometryData.stream().filter(p -> p.getWsAve() != null && p.getWsAve() < 35).collect(Collectors.toList());
     }
 
 }

+ 1 - 3
neim-biz/src/main/java/com/jiayue/biz/service/impl/StatisticsSituationServiceImpl.java

@@ -54,10 +54,8 @@ public class StatisticsSituationServiceImpl extends ServiceImpl<StatisticsSituat
                 }
             }
             // 新增统计概述信息
-            // 获取塔的接入时间:集合里第一条的time
-            WindTowerDataParentTable windTowerStatusData = windTowerDataParentTableService.getFirstData(windTowerInfo.getEquipmentNo());
             // 拼接起止时间
-            if (windTowerStatusData != null) {
+            if (dataTimeStartAndEnd != null) {
                 String time = dataTimeStartAndEnd.get("startTime") + "," + dataTimeStartAndEnd.get("endTime");
                 statisticsSituation.setEquipmentId(windTowerInfo.getEquipmentNo());
                 statisticsSituation.setStartTimeAndEndTime(time);