hxf 1 yıl önce
ebeveyn
işleme
a8d05a6b48

+ 4 - 1
wrdep-biz/src/main/java/com/jiayue/biz/job/AirDensityJob.java

@@ -93,7 +93,7 @@ public class AirDensityJob {
 
             } else {
                 List<Entity> firstRealData = prophaseWeatherDataService.getFirstData(windTowerInfo.getEquipmentNo());
-                if(firstRealData.size() > 0){
+                if (firstRealData.size() > 0) {
                     startDate = (Timestamp) firstRealData.get(0).get("first (ts)");
                 }
 
@@ -140,6 +140,9 @@ public class AirDensityJob {
             //日平均风功率密度
             ArrayList<WindTowerCalculationData> wpdDayList = windTowerCalculationDataService.wpdDay(startDate, endDate, windTowerInfo.getEquipmentNo(), windTowerCalculationDataList, equipmentAttributeList, windTowerInfoList);
             dataList.addAll(wpdDayList);
+            //风速在15m/s时湍流强度
+            ArrayList<WindTowerCalculationData> turForWsByFifteenDayList = windTowerCalculationDataService.turForWsByFifteenDay(startDate, endDate, windTowerInfo.getEquipmentNo(), prophaseAnemometryDataList, equipmentAttributeList, windTowerInfoList);
+            dataList.addAll(turForWsByFifteenDayList);
 
 
             //如果结束时间和数据统计的时间相差大于30天就分割月份进行计算

+ 4 - 3
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/AnalysisDataImpl.java

@@ -1267,7 +1267,6 @@ public class AnalysisDataImpl {
         List<CsvRow> rows = csvRows.getRows();
         CsvRow rowsOne = rows.get(1);
         CsvRow rowsF = rows.get(5);
-
         StringBuilder height = new StringBuilder();
         StringBuilder wdHeight = new StringBuilder();
         WindTowerInfo windTowerInfo = new WindTowerInfo();
@@ -1278,10 +1277,12 @@ public class AnalysisDataImpl {
 
         List<WindTowerInfo> equipmentNo = windTowerInfoService.getByEquipmentNo(windTowerInfo.getEquipmentNo());
         if (windTowerInfoType(windTowerInfo.getEquipmentNo())) {
-            if (equipmentNo.size() == 0) {
+            if (equipmentNo.size() == 0 || equipmentNo.get(0).getRecorderNo() == null) {
+                windTowerInfo = equipmentNo.get(0);
                 windTowerInfo.setHeights(height.toString());
                 windTowerInfo.setWdHeights(height.toString());
-                windTowerInfoService.saveWindTowerInfo(windTowerInfo);
+                windTowerInfo.setRecorderNo(rows.get(0).get(1));
+                windTowerInfoService.saveOrUpdate(windTowerInfo);
             }
             List<Map<String, Object>> mapList = parseByHead(rows, rowsOne);
             List<Map<String, Object>> mapList1 = new CheckDataRecode().checkValue(mapList, "dat");

+ 2 - 1
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/DataRecalculationImpl.java

@@ -652,7 +652,8 @@ public class DataRecalculationImpl implements DataRecalculationService {
             //日平均风切变
             ArrayList<WindTowerCalculationData> shearDay = windTowerCalculationDataService.shearDay(startTime, endTime, equipmentNo, windTowerCalculationDataList, equipmentAttributeList, windTowerInfoList, prophaseAnemometryDataList);
             allDataList.addAll(shearDay);
-
+            ArrayList<WindTowerCalculationData> turForWsByFifteenDayList = windTowerCalculationDataService.turForWsByFifteenDay(startTime, endTime, equipmentNo, prophaseAnemometryDataList, equipmentAttributeList, windTowerInfoList);
+            allDataList.addAll(turForWsByFifteenDayList);
 
             List<Long> dateTime = DateTimeUtil.getIntervalTimeByMonth(DateTimeUtil.beginOfMonth(startTime), DateTimeUtil.beginOfMonth(endTime));
             for (Long l : dateTime) {

+ 4 - 1
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/EmailImpl.java

@@ -554,6 +554,10 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
                     //把txt文件转成excel文件并解析
                     analysisDataService.analysisData(type);
                 }else if(type.equals("csv")){
+                    if(!subjectId.contains("[") || !subjectId.contains("]")){
+                        cn.hutool.core.io.FileUtil.del(f);
+                        continue;
+                    }
                     String id = subjectId.substring(subjectId.indexOf("[") + 1, subjectId.lastIndexOf("]"));
                     List<WindTowerInfo> equipmentNo = windTowerInfoService.getByEquipmentNo(id);
                     if(equipmentNo.size() == 0){
@@ -562,7 +566,6 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
                         analysisDataService.acousticRadar(f,id);
                     }
 
-
                 }else if(type.equals("dat")){
                     analysisDataService.parseByDat(f);
 

+ 382 - 281
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/PdfServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jiayue.biz.service.impl;
 
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -57,11 +58,12 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
             endDay = DateUtil.endOfDay(DateUtil.yesterday());
         }
         Map<String, Object> map = new HashMap<>();
-        long realityCount = 0;//数据实际条数
         // 一年的计算数据
         startDay = DateUtil.beginOfMonth(startDay);
         endDay = DateUtil.endOfMonth(endDay);
         List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataService.getByBetweenTimeAndEquipmentId(startDay, endDay, equipmentId);
+        //实时数据查询
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAndWdForTime(equipmentId, new Timestamp(startDay.getTime()), new Timestamp(endDay.getTime()));
         // 一年的风向统计数据
         List<WindDirectionStatisticsData> windDirectionStatisticsDataList = windDirectionStatisticsDataService.getByBetweenTimeAndEquipmentId(startDay, endDay, equipmentId);
         //所有类型数据
@@ -69,237 +71,116 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
         //所有测风塔信息
         List<WindTowerInfo> windTowerInfoList = windTowerInfoService.getAllWindTower();
         List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentId)).collect(Collectors.toList());
-//        List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
-        //计算完整性
-        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<String, Object> windTowerInfo = getWindTowerInfo(windTowerInfos, startDay, endDay);
         map.put("windTowerInfo", windTowerInfo);
-        //测风塔统计概要概要
-        Map<String, Object> statisticsData = statisticsWindTowerStatusData(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, realityCount, startDay, endDay);
+        //环境数据
+        Map<String, Object> statisticsData = statisticsWindTowerStatusData(windTowerCalculationDatas, equipmentAttributeList);
         map.put("statisticsData", statisticsData);
-        //风速和风功率密度时间曲线图 (时间序列)
-        Map<String, Object> wsAndWpd = getWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
-        map.put("wsAndWpd", wsAndWpd);
-        //风速和风速标准差时间曲线图
-        Map<String, Object> wsAndWsStaData = wsAndWsSta(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
-        map.put("wsAndWsStaData", wsAndWsStaData);
-        //风速和风速密度日变化
-        Map<String, Object> windPowerDensityAndAverageWindSpeed = getWindPowerDensityAndAverageWindSpeed(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, height);
-        map.put("windPowerDensityAndAverageWindSpeed", windPowerDensityAndAverageWindSpeed);
-        //风速和风速密度各月日变化
-        List<Map<String, Object>> MonthWsAndWpd = getMonthWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
-        map.put("MonthWsAndWpd", MonthWsAndWpd);
-        //风速和风速密度年变化曲线
-        Map<String, Object> yearWsAndWpd = getYearWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
-        map.put("yearWsAndWpd", yearWsAndWpd);
-        //风速和风速密度各月日变化表格
-        Map<String, Object> monthWpdTable = getMonthWpdTable(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, startDay, endDay);
-        map.put("monthWpdTable", monthWpdTable);
+        //风速最大、最小、平均 数据
+        ArrayList<Map<String, Object>> statisticsDataFen = statisticsWindTowerStatusDataFeng(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos);
+        map.put("statisticsDataFen", statisticsDataFen);
+        //风速每月平均
+        ArrayList<Map<String, Object>> statisticsWindTowerStatusDataFenMonth = statisticsWindTowerStatusDataFenMonth(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, startDay, endDay);
+        map.put("statisticsWindTowerStatusDataFenMonth", statisticsWindTowerStatusDataFenMonth);
+        //风功率密度每月平均
+        ArrayList<Map<String, Object>> statisticsWindTowerStatusDataFenWpd = statisticsWindTowerStatusDataWpd(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos);
+        map.put("statisticsWindTowerStatusDataFenWpd", statisticsWindTowerStatusDataFenWpd);
+        //一年玫瑰图 以及风能玫瑰图
+        ArrayList<Map<String, Object>> roseChart = roseCharts(windDirectionStatisticsDataList, equipmentAttributeList, windTowerInfos);
+        map.put("roseChart", roseChart);
         //pdf威布尔
-        Map<String, Object> weibull = pdfWeibull(equipmentAttributeList, equipmentId, windTowerCalculationDatas, height);
+        ArrayList<Map<String, Object>> weibull = pdfWeibull(equipmentAttributeList, windTowerCalculationDatas, windTowerInfos);
         map.put("weibull", weibull);
-        //一年玫瑰图
-        Map<String, Object> roseChart = roseCharts(windDirectionStatisticsDataList, equipmentAttributeList, height);
-        map.put("roseChart", roseChart);
-        //各月玫瑰图
-        Map<String, Object> monthRoseCharts = getMonthRoseCharts(windDirectionStatisticsDataList, equipmentAttributeList, height);
-        map.put("monthRoseCharts", monthRoseCharts);
-        //空气密度
-        Map<String, Object> airDensity = getAirDensity(windTowerCalculationDatas, equipmentAttributeList, startDay, endDay);
-        map.put("airDensity", airDensity);
-        //获取风切变指数(风向玫瑰图)
-        List<Map<String, Object>> windShearRose = getWindShearRose(windDirectionStatisticsDataList, equipmentAttributeList, height);
-        map.put("windShearRose", windShearRose);
-        //风切变日/年变化
-        Map<String, Object> windShear = getWindShear(windTowerCalculationDatas, equipmentAttributeList, height);
-        map.put("windShear", windShear);
-        //湍流曲线
-        List<List<BigDecimal>> turIntensityCharts = getTurIntensityCharts(windTowerCalculationDatas, equipmentAttributeList, height);
-        map.put("turIntensityCharts", turIntensityCharts);
-        //湍流日/年变化
-        Map<String, Object> turIntensity = getTurIntensity(windTowerCalculationDatas, equipmentAttributeList, height);
-        map.put("turIntensity", turIntensity);
-        //获取湍流(风向玫瑰图)
-        Map<String, Object> turIntensityRose = getTurIntensityRose(windDirectionStatisticsDataList, equipmentAttributeList, windTowerInfos.get(0), height);
-        map.put("turIntensityRose", turIntensityRose);
+        //15m/s湍流强度
+        ArrayList<Map<String, Object>> statisticsWindTowerStatusDataFenTur = statisticsWindTowerStatusDataTur(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos);
+        map.put("statisticsWindTowerStatusDataFenTur", statisticsWindTowerStatusDataFenTur);
+        //风切变
+        ArrayList<Object> statisticsWindTowerStatusDataShear = statisticsWindTowerStatusDataShear(prophaseAnemometryDataList, windTowerInfos);
+        map.put("statisticsWindTowerStatusDataShear", statisticsWindTowerStatusDataShear);
+
+//
+//        //风速和风功率密度时间曲线图 (时间序列)
+//        Map<String, Object> wsAndWpd = getWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
+//        map.put("wsAndWpd", wsAndWpd);
+//        //风速和风速标准差时间曲线图
+//        Map<String, Object> wsAndWsStaData = wsAndWsSta(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
+//        map.put("wsAndWsStaData", wsAndWsStaData);
+//        //风速和风速密度日变化
+//        Map<String, Object> windPowerDensityAndAverageWindSpeed = getWindPowerDensityAndAverageWindSpeed(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, height);
+//        map.put("windPowerDensityAndAverageWindSpeed", windPowerDensityAndAverageWindSpeed);
+//        //风速和风速密度各月日变化
+//        List<Map<String, Object>> MonthWsAndWpd = getMonthWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
+//        map.put("MonthWsAndWpd", MonthWsAndWpd);
+//        //风速和风速密度年变化曲线
+//        Map<String, Object> yearWsAndWpd = getYearWsAndWpd(windTowerCalculationDatas, equipmentAttributeList, height, startDay, endDay);
+//        map.put("yearWsAndWpd", yearWsAndWpd);
+//        //风速和风速密度各月日变化表格
+//        Map<String, Object> monthWpdTable = getMonthWpdTable(windTowerCalculationDatas, equipmentAttributeList, windTowerInfos, startDay, endDay);
+//        map.put("monthWpdTable", monthWpdTable);
+//
+//        //各月玫瑰图
+//        Map<String, Object> monthRoseCharts = getMonthRoseCharts(windDirectionStatisticsDataList, equipmentAttributeList, height);
+//        map.put("monthRoseCharts", monthRoseCharts);
+//
+//        //空气密度
+//        Map<String, Object> airDensity = getAirDensity(windTowerCalculationDatas, equipmentAttributeList, startDay, endDay);
+//        map.put("airDensity", airDensity);
+//        //获取风切变指数(风向玫瑰图)
+//        List<Map<String, Object>> windShearRose = getWindShearRose(windDirectionStatisticsDataList, equipmentAttributeList, height);
+//        map.put("windShearRose", windShearRose);
+//        //风切变日/年变化
+//        Map<String, Object> windShear = getWindShear(windTowerCalculationDatas, equipmentAttributeList, height);
+//        map.put("windShear", windShear);
+//        //湍流曲线
+//        List<List<BigDecimal>> turIntensityCharts = getTurIntensityCharts(windTowerCalculationDatas, equipmentAttributeList, height);
+//        map.put("turIntensityCharts", turIntensityCharts);
+//        //湍流日/年变化
+//        Map<String, Object> turIntensity = getTurIntensity(windTowerCalculationDatas, equipmentAttributeList, height);
+//        map.put("turIntensity", turIntensity);
+//        //获取湍流(风向玫瑰图)
+//        Map<String, Object> turIntensityRose = getTurIntensityRose(windDirectionStatisticsDataList, equipmentAttributeList, windTowerInfos.get(0), height);
+//        map.put("turIntensityRose", turIntensityRose);
         return map;
     }
 
     /**
      * 测风塔信息概要
      *
-     * @param windTowerCalculationDataList 统计数据
-     * @param equipmentAttributeList       属性数据
-     * @param windTowerInfos               测风塔信息
-     * @param height                       层高
-     * @param realityCount                 数据条数
      * @return
      */
-    public Map<String, Object> getWindTowerInfo(List<WindTowerCalculationData> windTowerCalculationDataList, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos, String height, long realityCount, Date startDay, Date endDay) {
+    public Map<String, Object> getWindTowerInfo(List<WindTowerInfo> windTowerInfos, Date startDay, Date endDay) {
         Map<String, Object> map = new HashMap<>();
-        try {
-            map.put("windInfo", windTowerInfos.get(0));
-            /*数据记录信息*/
-            Map<String, Object> dataMap = new HashMap<>();
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-            //如果查询月份等于当前时间月份就拿数据库最后一天数据的时间作为结束时间
-            if (endDay.getMonth() == new Date().getMonth()) {
-                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);
-            long totalCount = count * 144;//时间范围内的总条数
-            long deletionCount;//缺失条数
-            BigDecimal totalRate = BigDecimal.valueOf(0.0);//完整率
-            BigDecimal deletionRate = BigDecimal.valueOf(0.0);//缺失率
-            BigDecimal aveWs = new BigDecimal(0);//平均风速
-            //取出heigth层高的平均风速属性
-            List<EquipmentAttribute> equipmentAttributeList1 = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsMonth")).collect(Collectors.toList());
-            //取出这个层高所有的数据
-            List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(equipmentAttributeList1.get(0).getId())).collect(Collectors.toList());
+        Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(windTowerInfos.get(0).getEquipmentNo());
+        List<Entity> count = prophaseWeatherDataService.selectCount(windTowerInfos.get(0).getEquipmentNo());
+        long allCount = ((endDay.getTime() - startDay.getTime() + 1000) / 86400000l) * 144;
 
-            deletionCount = totalCount - realityCount;
-            if (!windTowerCalculationDataList1.isEmpty()) {
-                //做平均值
-                aveWs = windTowerCalculationDataList1.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(windTowerCalculationDataList1.size()), 2, RoundingMode.HALF_UP);
-            } else {
-                deletionCount = totalCount;
-            }
-            if (realityCount != 0L) {
-                totalRate = new BigDecimal(realityCount).divide(new BigDecimal(totalCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
-            }
-            if (deletionCount != 0L) {
-                deletionRate = new BigDecimal(deletionCount).divide(new BigDecimal(totalCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
-            }
+        BigDecimal percentage = BigDecimal.valueOf((Long) count.get(0).get("count(*)")).divide(BigDecimal.valueOf(allCount), 2, RoundingMode.HALF_UP);
 
-            dataMap.put("realityCount", realityCount);
-            dataMap.put("totalCount", totalCount);
-            dataMap.put("integrityRate", totalRate);
-            dataMap.put("deletionRate", deletionRate);
-            dataMap.put("ws", aveWs);
-            dataMap.put("time", sdf.format(startDay) + " - " + sdf.format(endDay));
-            map.put("dataInfo", dataMap);
-        } catch (Exception e) {
-            e.printStackTrace();
+
+        if (windTowerInfos.size() != 0) {
+            map.put("windTowerInfo", windTowerInfos.get(0));
+            map.put("startTime", DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd"));
+            map.put("endTime", DateUtil.format(new Date(dataTimeStartAndEnd.get("endTime")), "yyyy-MM-dd"));
+            map.put("count", count.get(0).get("count(*)"));
+            map.put("allCount", allCount);
+            map.put("percentage", percentage);
         }
         return map;
     }
 
 
     /**
-     * 测风塔统计概要概要
+     * 环境数据
      *
      * @param windTowerCalculationDatas 统计数据
      * @param equipmentAttributeList    属性数据
-     * @param windTowerInfos            测风塔信息
-     * @param realityCount              数据条数
      * @return
      */
-    public Map<String, Object> statisticsWindTowerStatusData(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos, long realityCount, Date startDay, Date endDay) {
+    public Map<String, Object> statisticsWindTowerStatusData(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList) {
         Map<String, Object> map = new HashMap<>();
         try {
             List<Map<String, Object>> dataList = new ArrayList<>();
-            //如果查询月份等于当前时间月份就拿数据库最后一天数据的时间作为结束时间
-            if (endDay.getMonth() == new Date().getMonth()) {
-                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);
-            long totalCount = count * 144;//时间范围内的总条数
-            // 根据设备属性表中的属性作用查询所有月平均湍流
-            List<EquipmentAttribute> turbulenceMonths = equipmentAttributeList.stream().filter(e -> "turbulenceMonth".equals(e.getAttributeFunction())).collect(Collectors.toList());
-            List<EquipmentAttribute> wpdMonths = equipmentAttributeList.stream().filter(e -> "WindPowerDensity".equals(e.getAttributeFunction())).collect(Collectors.toList());
-            String heights = windTowerInfos.get(0).getHeights();
-            if (heights == null || heights.equals("")) {
-                heights = "10,30,50,60,70,80,90,100,110,120,140,150";
-            }
-            String[] heightStrs = heights.split(",");
-            for (String height : heightStrs) {
-
-                Map<String, Object> dataMap = new HashMap<>();
-                long deletionCount;//缺失条数
-                BigDecimal integrityRate = BigDecimal.valueOf(0.0);//完整率
-                BigDecimal aveWs = new BigDecimal(0);//平均风速
-                BigDecimal maxWs = new BigDecimal(0);//最大风速
-                BigDecimal aveTur = new BigDecimal(0);//平均湍流
-                BigDecimal aveWpd = new BigDecimal(0);//平均风功率密度
-                //取出heigth层高的平均风速属性
-                List<EquipmentAttribute> equipmentAttributeList1 = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsMonth")).collect(Collectors.toList());
-                //取height层高的最大风速
-                List<EquipmentAttribute> equipmentAttributeListMaxws = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "maxwsMonth")).collect(Collectors.toList());
-                //取出这个层高所有的数据
-                List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttributeList1.get(0).getId())).collect(Collectors.toList());
-                //最大值
-                List<WindTowerCalculationData> windTowerCalculationDataMaxList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttributeListMaxws.get(0).getId())).sorted(Comparator.comparing(WindTowerCalculationData::getValue).reversed()).collect(Collectors.toList());
-
-                if (!windTowerCalculationDataList1.isEmpty()) {
-                    deletionCount = totalCount - realityCount;
-                    if (!windTowerCalculationDataList1.isEmpty()) {
-                        aveWs = windTowerCalculationDataList1.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(windTowerCalculationDataList1.size()), 2, RoundingMode.HALF_UP);
-                    }
-                    if (!windTowerCalculationDataMaxList.isEmpty()) {
-                        maxWs = windTowerCalculationDataMaxList.get(0).getValue();
-                    }
-                } else {
-                    deletionCount = totalCount;
-                }
-                if (realityCount != 0L) {
-                    integrityRate = new BigDecimal(realityCount).divide(new BigDecimal(totalCount), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
-                }
-                if (!turbulenceMonths.isEmpty()) {
-                    /*平均湍流*/
-                    String turbulenceMonth = height + "turbulenceMonth";
-                    // 过滤属性集合找对应的属性id
-                    List<EquipmentAttribute> turbulenceMonthAtt = turbulenceMonths.stream().filter(w -> w.getFieldName().equals(turbulenceMonth)).collect(Collectors.toList());
-                    String turEbId = turbulenceMonthAtt.get(0).getId();
-                    // 过滤一周数据
-                    List<WindTowerCalculationData> turbulenceMonthList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(turEbId)).collect(Collectors.toList());
-                    if (!turbulenceMonthList.isEmpty()) {
-                        aveTur = turbulenceMonthList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(turbulenceMonthList.size()), 2, RoundingMode.HALF_UP);
-                    }
-                }
-                if (!wpdMonths.isEmpty()) {
-                    /*平均风功率密度*/
-                    String wpdMonth = height + "wpdMonth";
-                    // 过滤属性集合找对应的属性id
-                    List<EquipmentAttribute> wpdMonthAtt = wpdMonths.stream().filter(w -> w.getFieldName().equals(wpdMonth)).collect(Collectors.toList());
-                    String wpdEbId = wpdMonthAtt.get(0).getId();
-                    // 过滤一周数据
-                    List<WindTowerCalculationData> wpdMonthList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(wpdEbId)).collect(Collectors.toList());
-                    if (!wpdMonthList.isEmpty()) {
-                        aveWpd = wpdMonthList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(wpdMonthList.size()), 2, RoundingMode.HALF_UP);
-                    }
-                }
-                dataMap.put("height", height);
-                dataMap.put("deletionCount", deletionCount);
-//                dataMap.put("freezeCount", 0);//结冰数据
-//                dataMap.put("abnormalCount", 0);//异常数据
-//                dataMap.put("lowDataQualityCount", 0);//质量低数据
-                dataMap.put("integrityRate", integrityRate);
-//                dataMap.put("efficiency", integrityRate);//有效率
-                dataMap.put("ws", aveWs);
-                dataMap.put("maxWs", maxWs);
-                dataMap.put("tur", aveTur);
-                dataMap.put("power", aveWpd);
-                dataList.add(dataMap);
-            }
             /*环境数据*/
             //从数据库属性表里查出环境数据的属性
             List<EquipmentAttribute> paMax = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("paMAX")).collect(Collectors.toList());
@@ -369,6 +250,122 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
     }
 
     /**
+     * 风速最大、最小、平均 数据
+     *
+     * @param windTowerCalculationDatas 统计数据
+     * @param equipmentAttributeList    属性数据
+     * @return
+     */
+    public ArrayList<Map<String, Object>> statisticsWindTowerStatusDataFeng(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Map<String, Object>> heightAndWsList = new ArrayList<>();
+
+        String[] heights = windTowerInfos.get(0).getHeights().split(",");
+
+        for (String height : heights) {
+            BigDecimal wsAve = BigDecimal.ZERO;
+            BigDecimal wsMax = BigDecimal.ZERO;
+            BigDecimal wsMin = BigDecimal.ZERO;
+            Map<String, Object> map = new HashMap<>();
+            List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsDay")).collect(Collectors.toList());
+            //通过属性过滤数据
+            List<WindTowerCalculationData> wsDayList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttributes.get(0).getId())).collect(Collectors.toList());
+            if (wsDayList.size() > 0) {
+                wsAve = wsDayList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(wsDayList.size()), 2, RoundingMode.HALF_UP);
+                wsMin = wsDayList.stream().map(WindTowerCalculationData::getValue).min(BigDecimal::compareTo).get();
+                wsMax = wsDayList.stream().map(WindTowerCalculationData::getValue).max((x1, x2) -> x1.compareTo(x2)).get();
+            }
+
+            map.put("wsAve", wsAve);
+            map.put("wsMin", wsMin);
+            map.put("wsMax", wsMax);
+            map.put("height", height);
+            heightAndWsList.add(map);
+
+        }
+        return heightAndWsList;
+    }
+
+    /**
+     * 风速每月平均
+     *
+     * @param windTowerCalculationDatas 统计数据
+     * @param equipmentAttributeList    属性数据
+     * @return
+     */
+    public ArrayList<Map<String, Object>> statisticsWindTowerStatusDataFenMonth(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos, Date startDay, Date endDay) {
+        ArrayList<Map<String, Object>> heightAndWsList = new ArrayList<>();
+        HashMap<String, Object> timeMap = new HashMap<>();
+        ArrayList<String> timeList = new ArrayList<>();
+        String[] heights = windTowerInfos.get(0).getHeights().split(",");
+        int i = 0;
+        for (String height : heights) {
+            HashMap<String, Object> heightMap = new HashMap<>();
+            List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsDay")).collect(Collectors.toList());
+            for (Long l = startDay.getTime(); l < endDay.getTime(); l = DateUtil.offsetMonth(new Date(l), 1).getTime()) {
+                Date startTime = DateUtil.beginOfMonth(new Date(l));
+                Date endTime = DateUtil.endOfMonth(startTime);
+                BigDecimal wsAve = BigDecimal.ZERO;
+
+                //通过属性过滤数据
+                List<WindTowerCalculationData> wsDayList = windTowerCalculationDatas.stream().filter(w -> w.getTime().getTime() >= startTime.getTime() &&
+                        w.getTime().getTime() <= endTime.getTime() &&
+                        w.getEbId().equals(equipmentAttributes.get(0).getId())).collect(Collectors.toList());
+                if (wsDayList.size() > 0) {
+                    wsAve = wsDayList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(wsDayList.size()), 2, RoundingMode.HALF_UP);
+                }
+                heightMap.put(DateUtil.format(startTime, "yyyy.M"), wsAve);
+                if (i == 0) {
+                    timeList.add(DateUtil.format(startTime, "yyyy.M"));
+                }
+            }
+            heightMap.put("height", height);
+            heightAndWsList.add(heightMap);
+            i++;
+        }
+        timeMap.put("timeTable", timeList);
+        heightAndWsList.add(timeMap);
+        return heightAndWsList;
+    }
+
+
+    /**
+     * 风功率密度最大、最小、平均 数据
+     *
+     * @param windTowerCalculationDatas 统计数据
+     * @param equipmentAttributeList    属性数据
+     * @return
+     */
+    public ArrayList<Map<String, Object>> statisticsWindTowerStatusDataWpd(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Map<String, Object>> heightAndWpdList = new ArrayList<>();
+
+        String[] heights = windTowerInfos.get(0).getHeights().split(",");
+
+        for (String height : heights) {
+            BigDecimal wpdAve = BigDecimal.ZERO;
+            BigDecimal wpdMax = BigDecimal.ZERO;
+            BigDecimal wpdMin = BigDecimal.ZERO;
+            Map<String, Object> map = new HashMap<>();
+            List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "wpdDay")).collect(Collectors.toList());
+            //通过属性过滤数据
+            List<WindTowerCalculationData> dayList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttributes.get(0).getId())).collect(Collectors.toList());
+            if (dayList.size() > 0) {
+                wpdAve = dayList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(dayList.size()), 2, RoundingMode.HALF_UP);
+                wpdMax = dayList.stream().map(WindTowerCalculationData::getValue).min(BigDecimal::compareTo).get();
+                wpdMin = dayList.stream().map(WindTowerCalculationData::getValue).max((x1, x2) -> x1.compareTo(x2)).get();
+            }
+
+            map.put("wpdAve", wpdAve);
+            map.put("wpdMin", wpdMax);
+            map.put("wpdMax", wpdMin);
+            map.put("height", height);
+            heightAndWpdList.add(map);
+
+        }
+        return heightAndWpdList;
+    }
+
+
+    /**
      * 测风塔数据时间范围
      *
      * @return
@@ -881,100 +878,202 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
     /**
      * pdf威布尔
      *
-     * @param height 层高
      * @return weibull
      */
-    public Map<String, Object> pdfWeibull(List<EquipmentAttribute> equipmentAttributeList, String equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList, String height) {
-        Map<String, Object> map = new HashMap<>();
-        List<BigDecimal> wsList = new ArrayList<>();
+    public ArrayList<Map<String, Object>> pdfWeibull(List<EquipmentAttribute> equipmentAttributeList, List<WindTowerCalculationData> windTowerCalculationDataList, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Map<String, Object>> weibullDataList = new ArrayList<>();
         try {
-            double e = 2.71828183;
-            // 风速集合
-            String ebId = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals(height + "aws")).collect(Collectors.toList()).get(0).getId();
+            String[] heightWs = windTowerInfos.get(0).getHeights().split(",");
+            for (String height : heightWs) {
+                Map<String, Object> map = new HashMap<>();
+                List<BigDecimal> wsList = new ArrayList<>();
+                double e = 2.71828183;
+                // 风速集合
+                String ebId = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals(height + "aws")).collect(Collectors.toList()).get(0).getId();
+
+                List<WindTowerCalculationData> calculationDataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(ebId)).collect(Collectors.toList());
+                for (WindTowerCalculationData w : calculationDataList) {
+                    wsList.add(w.getValue());
+                }
+
+                TreeMap<BigDecimal, List<BigDecimal>> wsMap = new TreeMap<>();
+
+                if (!wsList.isEmpty()) {
+                    ArrayList<Object> arrayWsList = new ArrayList<>(wsList);
+                    //把风速集合传入,计算A、K
+                    ProbabilityPlot probabilityPlot = new ProbabilityPlot(arrayWsList);
+                    probabilityPlot.suppressDisplay();
+                    double K = probabilityPlot.weibullTwoParGamma();
+                    double A = probabilityPlot.weibullTwoParSigma();
+
+
+                    map.put("K", BigDecimal.valueOf(K).setScale(2, RoundingMode.HALF_UP).doubleValue());
+                    map.put("A", BigDecimal.valueOf(A).setScale(2, RoundingMode.HALF_UP).doubleValue());
+                    BigDecimal wsAve = wsList.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(wsList.size()), 2, RoundingMode.HALF_UP);
+                    map.put("wsAve", wsAve);
+
+                    /*根据风速过滤出风速区间集合*/
+                    for (BigDecimal ws : wsList) {
+                        // 风速区间
+                        BigDecimal speedLevel = BigDecimal.valueOf(Math.ceil(ws.subtract(BigDecimal.valueOf(0.5)).doubleValue()));
+                        if (wsMap.containsKey(speedLevel)) {
+                            wsMap.get(speedLevel).add(ws);
+                        } else {
+                            wsMap.put(speedLevel, new ArrayList<>());
+                            wsMap.get(speedLevel.setScale(1, RoundingMode.HALF_UP)).add(ws);
+                        }
+                    }
 
-            List<WindTowerCalculationData> calculationDataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(ebId)).collect(Collectors.toList());
-            for (WindTowerCalculationData w : calculationDataList) {
-                wsList.add(w.getValue());
+                    /*风速频率*/
+                    List<List<BigDecimal>> wsFreList = new ArrayList<>();
+                    /*威布尔*/
+                    List<List<BigDecimal>> weibullList = new ArrayList<>();
+                    wsMap.forEach((key, val) -> {
+
+                        List<BigDecimal> list = new ArrayList<>();
+                        List<BigDecimal> tempList = new ArrayList<>();
+                        BigDecimal wsFrequency = new BigDecimal(val.size()).divide(new BigDecimal(wsList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+                        list.add(key.setScale(0, RoundingMode.HALF_UP));
+                        list.add(wsFrequency);
+                        wsFreList.add(list);
+
+                        /*区间威布尔累加求和求平均值*/
+                        BigDecimal aveWs = val.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(val.size()), 2, RoundingMode.HALF_UP);
+                        BigDecimal weibull = CalculationUtil.getBigDecimal(e, aveWs.doubleValue(), K, A);
+                        tempList.add(key.setScale(0, RoundingMode.HALF_UP));
+                        tempList.add(weibull);
+                        weibullList.add(tempList);
+                    });
+                    map.put("wsFrequency", wsFreList);
+                    map.put("weibull", weibullList);
+                    map.put("height", height);
+                }
+                weibullDataList.add(map);
             }
 
-            TreeMap<BigDecimal, List<BigDecimal>> wsMap = new TreeMap<>();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return weibullDataList;
+    }
 
-            if (!wsList.isEmpty()) {
-                ArrayList<Object> arrayWsList = new ArrayList<>(wsList);
-                //把风速集合传入,计算A、K
-                ProbabilityPlot probabilityPlot = new ProbabilityPlot(arrayWsList);
-                probabilityPlot.suppressDisplay();
-                double K = probabilityPlot.weibullTwoParGamma();
-                double A = probabilityPlot.weibullTwoParSigma();
 
+    /**
+     * 湍流(15m/s湍流)最大、最小、平均 数据
+     *
+     * @param windTowerCalculationDatas 统计数据
+     * @param equipmentAttributeList    属性数据
+     * @return
+     */
+    public ArrayList<Map<String, Object>> statisticsWindTowerStatusDataTur(List<WindTowerCalculationData> windTowerCalculationDatas, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Map<String, Object>> heightAndTurList = new ArrayList<>();
 
-                map.put("K", BigDecimal.valueOf(K).setScale(2, RoundingMode.HALF_UP).doubleValue());
-                map.put("A", BigDecimal.valueOf(A).setScale(2, RoundingMode.HALF_UP).doubleValue());
-                BigDecimal wsAve = wsList.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(wsList.size()), 2, RoundingMode.HALF_UP);
-                map.put("wsAve", wsAve);
+        String[] heights = windTowerInfos.get(0).getHeights().split(",");
 
-                /*根据风速过滤出风速区间集合*/
-                for (BigDecimal ws : wsList) {
-                    // 风速区间
-                    BigDecimal speedLevel = BigDecimal.valueOf(Math.ceil(ws.subtract(BigDecimal.valueOf(0.5)).doubleValue()));
-                    if (wsMap.containsKey(speedLevel)) {
-                        wsMap.get(speedLevel).add(ws);
-                    } else {
-                        wsMap.put(speedLevel, new ArrayList<>());
-                        wsMap.get(speedLevel.setScale(1, RoundingMode.HALF_UP)).add(ws);
-                    }
-                }
+        for (String height : heights) {
+            BigDecimal turAve = BigDecimal.ZERO;
+            BigDecimal turForFifteen = BigDecimal.ZERO;
+            Map<String, Object> map = new HashMap<>();
+            List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "turbulenceDay")).collect(Collectors.toList());
+            List<EquipmentAttribute> equipmentAttribute = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "turForWsByFifteenDay")).collect(Collectors.toList());
+            //通过属性过滤数据
+            List<WindTowerCalculationData> dayList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttributes.get(0).getId())).collect(Collectors.toList());
+            List<WindTowerCalculationData> turDayList = windTowerCalculationDatas.stream().filter(w -> w.getEbId().equals(equipmentAttribute.get(0).getId())).collect(Collectors.toList());
+            if (dayList.size() > 0) {
+                turAve = dayList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(dayList.size()), 2, RoundingMode.HALF_UP);
+            }
+            if (turDayList.size() > 0) {
+                turForFifteen = turDayList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(turDayList.size()), 2, RoundingMode.HALF_UP);
+            }
+
+            map.put("turAve", turAve);
+            map.put("turForFifteen", turForFifteen);
+            map.put("height", height);
+            heightAndTurList.add(map);
 
-                /*风速频率*/
-                List<List<BigDecimal>> wsFreList = new ArrayList<>();
-                /*威布尔*/
-                List<List<BigDecimal>> weibullList = new ArrayList<>();
-                wsMap.forEach((key, val) -> {
-
-                    List<BigDecimal> list = new ArrayList<>();
-                    List<BigDecimal> tempList = new ArrayList<>();
-                    BigDecimal wsFrequency = new BigDecimal(val.size()).divide(new BigDecimal(wsList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
-                    list.add(key.setScale(0, RoundingMode.HALF_UP));
-                    list.add(wsFrequency);
-                    wsFreList.add(list);
-
-                    /*区间威布尔累加求和求平均值*/
-                    BigDecimal aveWs = val.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(val.size()), 2, RoundingMode.HALF_UP);
-                    BigDecimal weibull = CalculationUtil.getBigDecimal(e, aveWs.doubleValue(), K, A);
-                    tempList.add(key.setScale(0, RoundingMode.HALF_UP));
-                    tempList.add(weibull);
-                    weibullList.add(tempList);
-                });
-                map.put("wsFrequency", wsFreList);
-                map.put("weibull", weibullList);
+        }
+        return heightAndTurList;
+    }
+
+    /**
+     * 风切变
+     *
+     * @return
+     */
+    public ArrayList<Object> statisticsWindTowerStatusDataShear(List<ProphaseAnemometryData> prophaseAnemometryData, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Object> wsShearTableData = new ArrayList<>();
+        HashMap<String, Object> heightMap = new HashMap<>();
+        String[] heights = windTowerInfos.get(0).getHeights().split(",");
+        for (String maxHeight : heights) {
+            HashMap<Object, Object> mainData = new HashMap<>();
+            if (maxHeight.contains("A")) {
+                continue;
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+            List<BigDecimal> maxHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(maxHeight)).map(p -> {
+                return CalculationUtil.getBigDecimal(p.getWsAve());
+            }).collect(Collectors.toList());
+            BigDecimal wsAveForMax = CalculationUtil.getAvgWind(maxHeightForWsList);
+            //筛选低层高
+            List<String> heightList = new ArrayList<>(Arrays.asList(heights)).stream().filter(s -> Integer.valueOf(CalculationUtil.getNumberFromString(maxHeight)) > Integer.valueOf(CalculationUtil.getNumberFromString(s))).collect(Collectors.toList());
+            //计算风切变
+            for (String minHeight : heightList) {
+                if (minHeight.contains("A")) {
+                    continue;
+                }
+                List<BigDecimal> minHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(minHeight)).map(p -> {
+                    return CalculationUtil.getBigDecimal(p.getWsAve());
+                }).collect(Collectors.toList());
+                BigDecimal wsAveMin = CalculationUtil.getAvgWind(minHeightForWsList);
+                double z = new BigDecimal(CalculationUtil.getNumberFromString(maxHeight)).divide(new BigDecimal(CalculationUtil.getNumberFromString(minHeight)), 8, RoundingMode.HALF_UP).doubleValue();
+                double z1 = Math.log10(z);
+                if (wsAveForMax.compareTo(BigDecimal.ZERO) > 0 && wsAveMin.compareTo(BigDecimal.ZERO) > 0 && z1 != 0) {
+                    BigDecimal shear = Convert.toBigDecimal(Math.log10(Convert.toDouble(wsAveForMax.divide(wsAveMin, 8, RoundingMode.HALF_UP))))
+                            .divide(BigDecimal.valueOf(z1), 2, RoundingMode.HALF_UP);
+
+
+                    mainData.put(minHeight, shear);
+//                    System.out.println(" height = " + maxHeight + "====" + wsAveForMax + "====" + minHeight + "====" + wsAveMin + "======" + shear);
+                }
+            }
+            mainData.put("height", maxHeight);
+
+
+            wsShearTableData.add(mainData);
+
         }
-        return map;
+        heightMap.put("headerData",Arrays.asList(heights));
+        wsShearTableData.add(heightMap);
+        return wsShearTableData;
     }
 
+
     /**
      * 一年玫瑰图
      *
-     * @param height 层高
+     * @param
      * @return
      * @throws Exception
      */
-    public Map<String, Object> roseCharts(List<WindDirectionStatisticsData> windDirectionStatisticsData, List<EquipmentAttribute> equipmentAttributeList, String height) {
-        Map<String, Object> map = new HashMap<>();
+    public ArrayList<Map<String, Object>> roseCharts(List<WindDirectionStatisticsData> windDirectionStatisticsData, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfos) {
+        ArrayList<Map<String, Object>> wdList = new ArrayList<>();
         try {
-            // 若层高包含A按照去掉A的层高计算
-            if (height.contains("A")) {
-                height = height.substring(0, height.length() - 1);
+            String[] heightWd = windTowerInfos.get(0).getWdHeights().split(",");
+            for (String height : heightWd) {
+                Map<String, Object> map = new HashMap<>();
+                // 若层高包含A按照去掉A的层高计算
+                if (height.contains("A")) {
+                    height = height.substring(0, height.length() - 1);
+                }
+                map.put("height", height);
+                map.put("wd", getwd(windDirectionStatisticsData, equipmentAttributeList, height));
+                map.put("power", getPower(windDirectionStatisticsData, equipmentAttributeList, height));
+                wdList.add(map);
             }
-            map.put("wd", getwd(windDirectionStatisticsData, equipmentAttributeList, height));
-            map.put("power", getPower(windDirectionStatisticsData, equipmentAttributeList, height));
         } catch (Exception e) {
             e.printStackTrace();
         }
 
-        return map;
+        return wdList;
     }
 
     /**
@@ -1042,14 +1141,14 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
             // 根据风向过滤统计表
             List<WindDirectionStatisticsData> filterWdList = wdList.stream().filter(e -> e.getDirection().equals(value.name())).collect(Collectors.toList());
             // 提取过滤的value值
-            List<BigDecimal> filterwdValueList = filterWdList.stream().map(WindDirectionStatisticsData::getValue).filter(w -> w != null).collect(Collectors.toList());
+//            List<BigDecimal> filterwdValueList = filterWdList.stream().map(WindDirectionStatisticsData::getValue).filter(w -> w != null).collect(Collectors.toList());
             // 累加保留两位小数
-            BigDecimal sumWd = null;
-            if (!filterwdValueList.isEmpty()) {
-                sumWd = filterwdValueList.stream().reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
+            BigDecimal proportionWd = BigDecimal.ZERO;
+            if (!filterWdList.isEmpty()) {
+                proportionWd = BigDecimal.valueOf(filterWdList.size()).divide(BigDecimal.valueOf(wdList.size()), 2, RoundingMode.HALF_UP);
             }
 
-            wdMap.put(value.name(), sumWd);
+            wdMap.put(value.name(), proportionWd);
             list.add(wdMap);
         }
         return list;
@@ -1063,20 +1162,22 @@ public class PdfServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper,
         List<EquipmentAttribute> powerEquipmentAttribute = equipmentAttributeList.stream().filter(e -> powerFieldName.equals(e.getFieldName())).collect(Collectors.toList());
         // 获取风向统计数据
         List<WindDirectionStatisticsData> powerList = windDirectionStatisticsData.stream().filter(e -> e.getEbId().equals(powerEquipmentAttribute.get(0).getId())).collect(Collectors.toList());
-
+        BigDecimal sumPower = powerList.stream().map(WindDirectionStatisticsData::getValue).reduce(BigDecimal::add).get();
         /*玫瑰图风向枚举*/
         for (WindDirectionEnum value : WindDirectionEnum.values()) {
             Map<String, Object> powerMap = new HashMap<>();
             // 根据风向过滤统计表
             List<WindDirectionStatisticsData> filterPowerList = powerList.stream().filter(e -> e.getDirection().equals(value.name())).collect(Collectors.toList());
-            // 提取过滤的value值
-            List<BigDecimal> filterPowerValueList = filterPowerList.stream().map(WindDirectionStatisticsData::getValue).filter(w -> w != null).collect(Collectors.toList());
+            BigDecimal sumPowerForWd = BigDecimal.ZERO;
+            if (filterPowerList.size() > 0) {
+                sumPowerForWd = filterPowerList.stream().filter(w -> w.getValue() != null).map(WindDirectionStatisticsData::getValue).reduce(BigDecimal::add).get();
+            }
             // 累加保留两位小数
-            BigDecimal sumPower = null;
-            if (!filterPowerValueList.isEmpty()) {
-                sumPower = filterPowerValueList.stream().reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP);
+            BigDecimal proportionPower = BigDecimal.ZERO;
+            if (sumPower.compareTo(BigDecimal.ZERO) > 0) {
+                proportionPower = sumPowerForWd.divide(sumPower, 2, RoundingMode.HALF_UP);
             }
-            powerMap.put(value.name(), sumPower);
+            powerMap.put(value.name(), proportionPower);
             list.add(powerMap);
         }
         return list;

+ 59 - 2
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerCalculationDataServiceImpl.java

@@ -507,7 +507,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
 
         DateTime startTimeYear = DateUtil.beginOfYear(new Date(startTime));
         DateTime endTimeYear = DateUtil.endOfYear(new Date(endTime));
-        List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = getByStartTimeBetweenAndEquipmentIdAndEbId(startTimeYear, endTimeYear, eqId,densityTypeList.get(0).getId());
+        List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = getByStartTimeBetweenAndEquipmentIdAndEbId(startTimeYear, endTimeYear, eqId, densityTypeList.get(0).getId());
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
         ArrayList<Object> PDataList = new ArrayList<>();
         for (long i = startTimeYear.getTime(); i <= endTimeYear.getTime(); i = DateUtil.offsetMonth(new Date(i), 12).getTime()) {
@@ -515,7 +515,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
             Date startTimeOfCurrentMonth = DateUtil.beginOfYear(new Date(i));
             //结束时间
             Date endTimeOfCurrentMonth = DateUtil.offsetMonth(new Date(i), 12);
-            List<WindTowerCalculationData> densityDataList = byBetweenTimeAndEquipmentId.stream().filter(w -> w.getTime().getTime() >= startTimeOfCurrentMonth.getTime() && w.getTime().getTime() <=endTimeOfCurrentMonth.getTime()&&
+            List<WindTowerCalculationData> densityDataList = byBetweenTimeAndEquipmentId.stream().filter(w -> w.getTime().getTime() >= startTimeOfCurrentMonth.getTime() && w.getTime().getTime() <= endTimeOfCurrentMonth.getTime() &&
                     w.getEbId().equals(densityId)).sorted(Comparator.comparing(WindTowerCalculationData::getTime)).collect(Collectors.toList());
 
             BigDecimal pSum = BigDecimal.ZERO;
@@ -1448,6 +1448,63 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
     }
 
     /**
+     * 计算15m/s湍流强度
+     *
+     * @param startTime   开始时间
+     * @param endTime     结束时间
+     * @param equipmentId 设备id
+     * @return
+     */
+    public ArrayList<WindTowerCalculationData> turForWsByFifteenDay(Date startTime, Date endTime, String equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfoList) {
+        long startHour = startTime.getTime();
+        long endHour = endTime.getTime();
+        long dayTime = 86400000L;
+        String heights = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentId)).collect(Collectors.toList()).get(0).getHeights();
+        String[] heightAll = heights.split(",");
+        //获取对应测风塔数据
+        ArrayList<WindTowerCalculationData> list = new ArrayList<>();
+        try {
+            for (String h : heightAll) {
+                List<EquipmentAttribute> turList = equipmentAttributeList.stream().filter(equipmentAttribute -> equipmentAttribute.getFieldName().equals(h + "turForWsByFifteenDay")).collect(Collectors.toList());
+
+                removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, turList.get(0).getId());
+                for (long start1 = startHour; start1 < endHour; start1 = start1 + dayTime) {
+                    long finalStart = start1;
+                    List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= finalStart && p.getTs().getTime() < finalStart + dayTime &&
+                            p.getLayerHeight().equals(h) && p.getWsAve() > 14.5 && p.getWsAve() <= 15.5).collect(Collectors.toList());
+
+                    if (anemometryDataList.size() > 0) {
+                        BigDecimal wsAve = anemometryDataList.stream().map(p -> {
+                            return BigDecimal.valueOf(p.getWsAve());
+                        }).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
+
+                        BigDecimal staAve = anemometryDataList.stream().map(p -> {
+                            return BigDecimal.valueOf(p.getWsSta());
+                        }).reduce(BigDecimal::add).get().divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
+
+                        //数据入库
+                        WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
+                        windTowerCalculationData.setTime(new Date(start1));
+                        windTowerCalculationData.setEbId(turList.get(0).getId());
+                        windTowerCalculationData.setEquipmentId(equipmentId);
+                        windTowerCalculationData.setValue(CalculationUtil.caTurbulenceIntensity(staAve, wsAve));
+                        list.add(windTowerCalculationData);
+                    }
+                }
+
+
+            }
+        } catch (NumberFormatException e) {
+            log.error("设备编号{}15m/s湍流计算失败^ ^", equipmentId);
+            e.printStackTrace();
+        }
+//        saveBatchByEquipmentId(list, equipmentId);
+        log.info("设备编号{}15m/s湍流计算成功^ ^", equipmentId);
+        return list;
+    }
+
+
+    /**
      * 计算月平均风功率密度
      *
      * @param startTime   开始时间

+ 12 - 12
wrdep-biz/src/main/java/com/jiayue/biz/util/CalculationUtil.java

@@ -54,7 +54,6 @@ public class CalculationUtil {
     }
 
 
-
     /**
      * 根据层高获取风速数据 todo 旧
      *
@@ -359,7 +358,7 @@ public class CalculationUtil {
         BigDecimal total = BigDecimal.ZERO;
 
         for (String maxHeight : heights) {
-            if(maxHeight.contains( "A")){
+            if (maxHeight.contains("A")) {
                 continue;
             }
             List<BigDecimal> maxHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(maxHeight)).map(p -> {
@@ -370,17 +369,17 @@ public class CalculationUtil {
             List<String> heightList = new ArrayList<>(Arrays.asList(heights)).stream().filter(s -> Integer.valueOf(CalculationUtil.getNumberFromString(maxHeight)) > Integer.valueOf(CalculationUtil.getNumberFromString(s))).collect(Collectors.toList());
             //计算风切变
             for (String minHeight : heightList) {
-                if(minHeight.contains( "A")){
+                if (minHeight.contains("A")) {
                     continue;
                 }
                 List<BigDecimal> minHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(minHeight)).map(p -> {
                     return getBigDecimal(p.getWsAve());
                 }).collect(Collectors.toList());
                 BigDecimal wsAveMin = getAvgWind(minHeightForWsList);
-                double z = new BigDecimal(getNumberFromString(maxHeight)).divide(new BigDecimal(getNumberFromString(minHeight)),8,RoundingMode.HALF_UP).doubleValue();
+                double z = new BigDecimal(getNumberFromString(maxHeight)).divide(new BigDecimal(getNumberFromString(minHeight)), 8, RoundingMode.HALF_UP).doubleValue();
                 double z1 = Math.log10(z);
-                if(wsAveForMax.compareTo(BigDecimal.ZERO) > 0 && wsAveMin.compareTo(BigDecimal.ZERO) > 0 && z1 != 0){
-                    BigDecimal shear = Convert.toBigDecimal(Math.log10(Convert.toDouble(wsAveForMax.divide(wsAveMin,8,RoundingMode.HALF_UP))))
+                if (wsAveForMax.compareTo(BigDecimal.ZERO) > 0 && wsAveMin.compareTo(BigDecimal.ZERO) > 0 && z1 != 0) {
+                    BigDecimal shear = Convert.toBigDecimal(Math.log10(Convert.toDouble(wsAveForMax.divide(wsAveMin, 8, RoundingMode.HALF_UP))))
                             .divide(BigDecimal.valueOf(z1), 8, RoundingMode.HALF_UP);
                     sumWShear = sumWShear.add(shear);
                     total = total.add(BigDecimal.ONE);
@@ -429,7 +428,7 @@ public class CalculationUtil {
     }
 
     public static void main(String[] args) {
-        Double[] doubles = {0.97,1.01,0.97,1.23,1.23,1.23,1.23,1.38,1.38,1.54};
+        Double[] doubles = {0.97, 1.01, 0.97, 1.23, 1.23, 1.23, 1.23, 1.38, 1.38, 1.54};
 
         List<Double> list = Arrays.asList(doubles);
 
@@ -440,26 +439,27 @@ public class CalculationUtil {
 
     /**
      * 计算标差
+     *
      * @param numArray 数据数组
      * @return 标差
      */
     public static BigDecimal calculateSD(List<Double> numArray) {
         double sum = 0.0, standardDeviation = 0.0;
         int length = numArray.size();
-        if(length == 0){
+        if (length == 0) {
             return BigDecimal.ZERO;
         }
-        for(double num : numArray) {
+        for (double num : numArray) {
             sum += num;
         }
 
-        double mean = sum/length;
+        double mean = sum / length;
 
-        for(double num: numArray) {
+        for (double num : numArray) {
             standardDeviation += Math.pow(num - mean, 2);
         }
 
-        return BigDecimal.valueOf(Math.sqrt(standardDeviation/length)).setScale(2, RoundingMode.HALF_UP);
+        return BigDecimal.valueOf(Math.sqrt(standardDeviation / length)).setScale(2, RoundingMode.HALF_UP);
     }
 
 }