fanxiaoyu 8 miesięcy temu
rodzic
commit
a4a17e3ba5
16 zmienionych plików z 285 dodań i 87 usunięć
  1. 4 4
      cpp-admin/src/main/java/com/cpp/web/controller/configManager/ParsingLogController.java
  2. 93 26
      cpp-admin/src/main/java/com/cpp/web/controller/reportData/ReportDataController.java
  3. 2 2
      cpp-admin/src/main/java/com/cpp/web/domain/datafactory/enums/FileTypeEnum.java
  4. 12 0
      cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlanRecords.java
  5. 2 2
      cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerShortTermCloudMapper.java
  6. 2 0
      cpp-admin/src/main/java/com/cpp/web/service/accuracy/AccuracyPassRateService.java
  7. 14 0
      cpp-admin/src/main/java/com/cpp/web/service/accuracy/impl/AccuracyPassRateServiceImpl.java
  8. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerShortTermCloudService.java
  9. 2 2
      cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerShortTermCloudServiceImpl.java
  10. 1 4
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingLogServiceImpl.java
  11. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanService.java
  12. 91 13
      cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanServiceImpl.java
  13. 49 19
      cpp-admin/src/main/java/com/cpp/web/service/powerGeneation/impl/DayPowerGenerationServiceImpl.java
  14. 6 4
      cpp-ui/src/views/statistics/analyzeRecords/index.vue
  15. 2 8
      cpp-ui/src/views/statistics/predictedPowerGeneration/index.vue
  16. 3 1
      cpp-ui/src/views/statistics/reportData/index.vue

+ 4 - 4
cpp-admin/src/main/java/com/cpp/web/controller/configManager/ParsingLogController.java

@@ -41,9 +41,9 @@ public class ParsingLogController {
 
     @ApiOperation(value = "根据场站编号分页查询", notes = "分页查询")
     @GetMapping("/getByStationCodeAndCreateTimeAndFileType")
-    public R getByStationCodeAndCreateTimeAndFileType(Long currentPage, Long pageSize, String stationCode, Long startTime,Long endTime, String fileType,String dataSources,String parsingDescribe,String parsingFileStatus) {
-        Page page = new Page(currentPage, pageSize);
-        page.setMaxLimit((long) -1);
-        return R.ok(parsingLogService.page(page, parsingLogService.getByStationCodeAndCreateTimeAndFileType(stationCode, new Date(startTime), new Date(endTime), fileType,dataSources,parsingDescribe,parsingFileStatus)));
+    public R getByStationCodeAndCreateTimeAndFileType(Long page, Long size, String stationCode, Long startTime,Long endTime, String fileType,String dataSources,String parsingDescribe,String parsingFileStatus) {
+        Page pages = new Page(page, size);
+        pages.setMaxLimit((long) -1);
+        return R.ok(parsingLogService.page(pages, parsingLogService.getByStationCodeAndCreateTimeAndFileType(stationCode, new Date(startTime), new Date(endTime), fileType,dataSources,parsingDescribe,parsingFileStatus)));
     }
 }

+ 93 - 26
cpp-admin/src/main/java/com/cpp/web/controller/reportData/ReportDataController.java

@@ -52,48 +52,109 @@ public class ReportDataController {
      */
     @GetMapping("/getData")
     public R getData(String stationCode, String fileType, Long startTime, Long endTime) {
-        // 获取应上报文件名
-        List<String> shouldFileName = reportDataService.shouldFileName(fileType, startTime, endTime, stationCode);
-        List<ParsingLog> parsingLogList = parsingLogService.findByTimeBetweenAndFileTypeAndStationCode(new Date(startTime), new Date(endTime), fileType, stationCode);
+
+        // 获取场站类型
+        ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+
+        String electricFieldTypeEnum = electricField.getElectricFieldTypeEnum();
+
+        List<FileTypeEnum> fileTypeEnumList = new ArrayList<>();
         List<ParsingLog> resultList = new ArrayList<>();
-        if (parsingLogList.size() > 0) {
-            resultList.addAll(parsingLogList);
-            for (int i = 0; i < shouldFileName.size(); i++) {
-                int finalI = i;
-                List<ParsingLog> collectList = parsingLogList.stream().filter(f -> f.getFileName().contains(shouldFileName.get(finalI))).collect(Collectors.toList());
-                if (collectList.size() > 0) {
-                    continue;
-                } else {
+
+        if (null == fileType) {
+            if (electricFieldTypeEnum.equals("E1")) {
+                fileTypeEnumList = FileTypeEnum.getPhotovoltaicFileType();
+            } else {
+                fileTypeEnumList = FileTypeEnum.getWindFileType();
+            }
+        }
+        if (fileTypeEnumList.size() > 0 && null != fileTypeEnumList){
+            // 获取应上报文件名
+            List<String> shouldFileName = reportDataService.shouldFileName(fileType, startTime, endTime, stationCode);
+            List<ParsingLog> parsingLogList = parsingLogService.findByTimeBetweenAndFileTypeAndStationCode(new Date(startTime), new Date(endTime), fileType, stationCode);
+            if (parsingLogList.size() > 0) {
+                resultList.addAll(parsingLogList);
+                for (int i = 0; i < shouldFileName.size(); i++) {
+                    int finalI = i;
+                    List<ParsingLog> collectList = parsingLogList.stream().filter(f -> f.getFileName().contains(shouldFileName.get(finalI))).collect(Collectors.toList());
+                    if (collectList.size() > 0) {
+                        continue;
+                    } else {
+                        ParsingLog parsingLogs = new ParsingLog();
+                        parsingLogs.setDataSources(DataSourcesEnum.E1);
+                        if ("dq".equals(fileType) || "nwp".equals(fileType)) {
+                            parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
+                        }
+                        if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
+                            parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_" + fileType.toUpperCase() + ".WPD");
+                        }
+                        parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
+                        parsingLogs.setParsingFileStatus("失败");
+                        parsingLogs.setStationCode(stationCode);
+                        resultList.add(parsingLogs);
+                    }
+                }
+            } else {
+                for (int i = 0; i < shouldFileName.size(); i++) {
                     ParsingLog parsingLogs = new ParsingLog();
-                    parsingLogs.setDataSources(DataSourcesEnum.E1);
                     if ("dq".equals(fileType) || "nwp".equals(fileType)) {
                         parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
                     }
                     if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
                         parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_" + fileType.toUpperCase() + ".WPD");
                     }
-                    parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
                     parsingLogs.setParsingFileStatus("失败");
                     parsingLogs.setStationCode(stationCode);
+                    parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
+                    parsingLogs.setDataSources(DataSourcesEnum.E1);
                     resultList.add(parsingLogs);
                 }
             }
-        } else {
-            for (int i = 0; i < shouldFileName.size(); i++) {
-                ParsingLog parsingLogs = new ParsingLog();
-                if ("dq".equals(fileType) || "nwp".equals(fileType)) {
-                    parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
+        }else {
+            // 获取应上报文件名
+            List<String> shouldFileName = reportDataService.shouldFileName(fileType, startTime, endTime, stationCode);
+            List<ParsingLog> parsingLogList = parsingLogService.findByTimeBetweenAndFileTypeAndStationCode(new Date(startTime), new Date(endTime), fileType, stationCode);
+            if (parsingLogList.size() > 0) {
+                resultList.addAll(parsingLogList);
+                for (int i = 0; i < shouldFileName.size(); i++) {
+                    int finalI = i;
+                    List<ParsingLog> collectList = parsingLogList.stream().filter(f -> f.getFileName().contains(shouldFileName.get(finalI))).collect(Collectors.toList());
+                    if (collectList.size() > 0) {
+                        continue;
+                    } else {
+                        ParsingLog parsingLogs = new ParsingLog();
+                        parsingLogs.setDataSources(DataSourcesEnum.E1);
+                        if ("dq".equals(fileType) || "nwp".equals(fileType)) {
+                            parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
+                        }
+                        if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
+                            parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_" + fileType.toUpperCase() + ".WPD");
+                        }
+                        parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
+                        parsingLogs.setParsingFileStatus("失败");
+                        parsingLogs.setStationCode(stationCode);
+                        resultList.add(parsingLogs);
+                    }
                 }
-                if ("status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
-                    parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_" + fileType.toUpperCase() + ".WPD");
+            } else {
+                for (int i = 0; i < shouldFileName.size(); i++) {
+                    ParsingLog parsingLogs = new ParsingLog();
+                    if ("dq".equals(fileType) || "nwp".equals(fileType)) {
+                        parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
+                    }
+                    if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
+                        parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_" + fileType.toUpperCase() + ".WPD");
+                    }
+                    parsingLogs.setParsingFileStatus("失败");
+                    parsingLogs.setStationCode(stationCode);
+                    parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
+                    parsingLogs.setDataSources(DataSourcesEnum.E1);
+                    resultList.add(parsingLogs);
                 }
-                parsingLogs.setParsingFileStatus("失败");
-                parsingLogs.setStationCode(stationCode);
-                parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
-                parsingLogs.setDataSources(DataSourcesEnum.E1);
-                resultList.add(parsingLogs);
             }
         }
+
+        // 定义比较器
         Comparator<ParsingLog> timestampComparator = new Comparator<ParsingLog>() {
             @Override
             public int compare(ParsingLog o1, ParsingLog o2) {
@@ -119,7 +180,13 @@ public class ReportDataController {
      */
     private static String extractAndParseTimestamp(String fileName) {
         String[] fileNameParts = fileName.split("_");
-        String correctTimestampStr = fileNameParts[1] + fileNameParts[2];
+        String correctTimestampStr = "";
+        if (fileName.contains("NWP")) {
+            correctTimestampStr = fileNameParts[1] + "0000".trim();
+        } else {
+            correctTimestampStr = fileNameParts[1] + fileNameParts[2];
+        }
+
         return correctTimestampStr;
     }
 }

+ 2 - 2
cpp-admin/src/main/java/com/cpp/web/domain/datafactory/enums/FileTypeEnum.java

@@ -25,7 +25,7 @@ public enum FileTypeEnum {
     private String message;
 
     // 风电上报类型
-    public List<FileTypeEnum> getWindFileType(){
+    public static List<FileTypeEnum> getWindFileType(){
         List<FileTypeEnum> fileTypeEnumList = new ArrayList<>();
         fileTypeEnumList.add(FileTypeEnum.dq);
         fileTypeEnumList.add(FileTypeEnum.cdq);
@@ -40,7 +40,7 @@ public enum FileTypeEnum {
     }
 
     // 光伏上报文件
-    public List<FileTypeEnum> getPhotovoltaicFileType(){
+    public static List<FileTypeEnum> getPhotovoltaicFileType(){
         List<FileTypeEnum> fileTypeEnumList = new ArrayList<>();
         fileTypeEnumList.add(FileTypeEnum.dq);
         fileTypeEnumList.add(FileTypeEnum.cdq);

+ 12 - 0
cpp-admin/src/main/java/com/cpp/web/domain/overhaulplan/OverhaulPlanRecords.java

@@ -49,4 +49,16 @@ public class OverhaulPlanRecords extends BaseCppEntity {
     @ApiModelProperty(value = "详情")
     private String details;
 
+
+    public OverhaulPlanRecords(Long opId, String forecastModel, FileTypeEnum forecastType, String details,String stationCode) {
+        this.opId = opId;
+        this.forecastModel = forecastModel;
+        this.forecastType = forecastType;
+        this.details = details;
+        super.setStationCode(stationCode);
+    }
+
+
+    public OverhaulPlanRecords() {
+    }
 }

+ 2 - 2
cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerShortTermCloudMapper.java

@@ -22,8 +22,8 @@ public interface ForecastPowerShortTermCloudMapper extends BaseMapper<ForecastPo
             "           ROW_NUMBER() OVER (PARTITION BY time ORDER BY forecast_how_long_ago ASC) as rn  \n" +
             "    FROM cpp_forecast_power_short_term_cloud  \n" +
             "    WHERE station_code = #{stationCode}  \n" +
-            "      AND time BETWEEN #{startTime} AND #{endTime}  \n" +
+            "      AND time BETWEEN #{startTime} AND #{endTime} And forecast_model = #{forecastModel} \n" +
             ") subquery  \n" +
             "WHERE rn = 1;")
-    List<ForecastPowerShortTermCloud> findByTimeBetweenAndStationCode(@Param("stationCode") String stationCode,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
+    List<ForecastPowerShortTermCloud> findByTimeBetweenAndStationCode(@Param("stationCode") String stationCode,@Param("startTime") Date startTime,@Param("endTime") Date endTime,@Param("forecastModel") String forecastModel);
 }

+ 2 - 0
cpp-admin/src/main/java/com/cpp/web/service/accuracy/AccuracyPassRateService.java

@@ -16,4 +16,6 @@ import java.util.List;
  */
 public interface AccuracyPassRateService extends IService<AccuracyPassRate> {
     List<AccuracyPassRate> findByTimeBetweenAndForecastTypeAndDataSourcesAndAgoAndForecastModelAndStationCode(Date startTime, Date endTime, ForecastTypeEnum forecastType, DataSourcesEnum dataSources,Integer ago, String forecastModel,String stationCode);
+
+    List<AccuracyPassRate> findByTimeBetweenAndStationCode(Date startTime,Date endTime,String stationCode);
 }

+ 14 - 0
cpp-admin/src/main/java/com/cpp/web/service/accuracy/impl/AccuracyPassRateServiceImpl.java

@@ -45,4 +45,18 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
         }
         return baseMapper.selectList(wrapper);
     }
+
+    @Override
+    public List<AccuracyPassRate> findByTimeBetweenAndStationCode(Date startTime, Date endTime, String stationCode) {
+        QueryWrapper<AccuracyPassRate> wrapper = new QueryWrapper<>();
+        if (null != startTime && null != endTime){
+            wrapper.between("time",startTime,endTime);
+        }
+        if (null != stationCode && !"".equals(stationCode)){
+            wrapper.eq("station_code",stationCode);
+        }
+        wrapper.eq("data_sources","E2");
+        wrapper.eq("forecast_how_long_ago",1);
+        return list(wrapper);
+    }
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerShortTermCloudService.java

@@ -30,5 +30,5 @@ public interface ForecastPowerShortTermCloudService extends IService<ForecastPow
 
     List<ForecastPowerShortTermCloud> findByForecastTimeBetweenAndHowLongAgoAndStationCode(Date startTime, Date endTime, Integer howLongAgo, String stationCode);
 
-    List<ForecastPowerShortTermCloud> findByForecastTimeBetweenAndStationCode(Date startTime,Date endTime,String stationCode);
+    List<ForecastPowerShortTermCloud> findByForecastTimeBetweenAndStationCode(Date startTime,Date endTime,String stationCode,String forecastModel);
 }

+ 2 - 2
cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerShortTermCloudServiceImpl.java

@@ -80,8 +80,8 @@ public class ForecastPowerShortTermCloudServiceImpl extends ServiceImpl<Forecast
     }
 
     @Override
-    public List<ForecastPowerShortTermCloud> findByForecastTimeBetweenAndStationCode(Date startTime, Date endTime, String stationCode) {
-        return forecastPowerShortTermCloudMapper.findByTimeBetweenAndStationCode(stationCode,startTime,endTime);
+    public List<ForecastPowerShortTermCloud> findByForecastTimeBetweenAndStationCode(Date startTime, Date endTime, String stationCode,String forecastModel) {
+        return forecastPowerShortTermCloudMapper.findByTimeBetweenAndStationCode(stationCode,startTime,endTime,forecastModel);
 
     }
 

+ 1 - 4
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingLogServiceImpl.java

@@ -74,10 +74,7 @@ public class ParsingLogServiceImpl extends ServiceImpl<ParsingLogMapper, Parsing
         if ("notNull".equals(parsingDescribe)) {
             wrapper.ne("parsing_describe", "");
         }
-        if (null != parsingFileStatus && !"".equals(parsingFileStatus) && "成功".equals(parsingFileStatus)) {
-            wrapper.eq("parsing_file_status", parsingFileStatus);
-        }
-        if (null != parsingFileStatus && !"".equals(parsingFileStatus) && "失败".equals(parsingFileStatus)) {
+        if (null != parsingFileStatus && !"".equals(parsingFileStatus) && ("成功".equals(parsingFileStatus) || "失败".equals(parsingFileStatus))) {
             wrapper.eq("parsing_file_status", parsingFileStatus);
         }
         return wrapper;

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/OverhaulPlanService.java

@@ -22,7 +22,7 @@ public interface OverhaulPlanService extends IService<OverhaulPlan> {
 
     List<OverhaulPlan> findByStationCode(String stationCode);
 
-    List<OverhaulPlan> findByStationCodeAndTimeBetween(Date date,String stationCode);
+    List<OverhaulPlan> findByStationCodeAndTimeBetween(Date startTime,Date endTime,String stationCode);
 
     List getCorrectionData(List<BaseForecastEntity> list, String fileType, String fileName, String stationCode);
 

+ 91 - 13
cpp-admin/src/main/java/com/cpp/web/service/overhaulplan/impl/OverhaulPlanServiceImpl.java

@@ -9,17 +9,18 @@ import com.cpp.web.domain.overhaulplan.OverhaulPlanRecords;
 import com.cpp.web.domain.station.ElectricField;
 import com.cpp.web.mapper.overhaulplan.OverhaulPlanMapper;
 import com.cpp.web.service.overhaulplan.OverhaulPlanRecordsService;
+
 import com.cpp.web.service.overhaulplan.OverhaulPlanService;
 import com.cpp.web.service.station.ElectricFieldService;
+import lombok.Data;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
-import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * cpp_overhaul_plan
@@ -73,19 +74,22 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
     @Override
     public List<OverhaulPlan> findByStationCode(String stationCode) {
         QueryWrapper<OverhaulPlan> wrapper = new QueryWrapper<>();
-        if (null != stationCode && !"".equals(stationCode)){
-            wrapper.eq("station_code",stationCode);
+        if (null != stationCode && !"".equals(stationCode)) {
+            wrapper.eq("station_code", stationCode);
         }
-        wrapper.eq("status",1);
+        wrapper.eq("status", 1);
         return list(wrapper);
     }
 
     @Override
-    public List<OverhaulPlan> findByStationCodeAndTimeBetween(Date date, String stationCode) {
+    public List<OverhaulPlan> findByStationCodeAndTimeBetween(Date startTime, Date endTime, String stationCode) {
         QueryWrapper<OverhaulPlan> wrapper = new QueryWrapper<>();
-        if (null != date) {
-            wrapper.ge("start_time", date);
-            wrapper.le("end_time", date);
+        if (startTime != null && !endTime.equals("") && endTime != null && !endTime.equals("")) {
+            wrapper.and(a -> a.or(w -> w.isNull("end_time").le("start_time", endTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", endTime).gt("end_time", startTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", endTime).gt("start_time", startTime))
+                    .or(w -> w.isNotNull("end_time").le("end_time", endTime).gt("start_time", endTime))
+                    .or(w -> w.isNotNull("end_time").le("start_time", startTime).gt("end_time", endTime)));
         }
         if (null != stationCode && !"".equals(stationCode)) {
             wrapper.eq("station_code", stationCode);
@@ -98,13 +102,87 @@ public class OverhaulPlanServiceImpl extends ServiceImpl<OverhaulPlanMapper, Ove
      * 返回修正后数据
      *
      * @param list
-     * @param <T>
      * @return
      */
     @Override
-    public  List<BaseForecastEntity> getCorrectionData(List<BaseForecastEntity> list, String fileType, String fileName, String stationCode) {
+    public List getCorrectionData(List<BaseForecastEntity> list, String fileType, String fileName, String stationCode) {
+
+        BigDecimal capacity;
+        List<BaseForecastEntity> resultList = new ArrayList<>();
+        List<OverhaulPlanRecords> overhaulPlanRecordsList = new ArrayList<>();
+        Date startTime;
+        Date endTime;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 获取场站装机容量
+        ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+        if (null != electricField) {
+            capacity = electricField.getCapacity();
+        } else {
+            capacity = BigDecimal.ZERO;
+        }
+        if (null != list && list.size() > 0) {
+            list.stream().sorted(Comparator.comparing(BaseForecastEntity::getTime));
+            startTime = list.get(0).getTime();
+            endTime = list.get(list.size() - 1).getTime();
+
+            // 查询检修计划
+            List<OverhaulPlan> overhaulPlanList = findByStationCodeAndTimeBetween(startTime, endTime, stationCode);
+
+            List<PlanDto> planDtos = new ArrayList<>();
+
+            for (OverhaulPlan overhaulPlan : overhaulPlanList) {
+                PlanDto planDto;
+                if (overhaulPlan.getStartTime().before(startTime) && overhaulPlan.getEndTime().after(endTime)) {
+                    planDto = new PlanDto(startTime, endTime, overhaulPlan, capacity);
+                } else if (overhaulPlan.getStartTime().before(startTime)) {
+                    planDto = new PlanDto(startTime, overhaulPlan.getEndTime(), overhaulPlan, capacity);
+                } else if (overhaulPlan.getEndTime().after(endTime)) {
+                    planDto = new PlanDto(overhaulPlan.getStartTime(), endTime, overhaulPlan, capacity);
+                } else {
+                    planDto = new PlanDto(overhaulPlan.getStartTime(), overhaulPlan.getEndTime(), overhaulPlan, capacity);
+                }
+                planDtos.add(planDto);
+                overhaulPlanRecordsList.add(new OverhaulPlanRecords(overhaulPlan.getId(), list.get(0).getForecastModel(), FileTypeEnum.valueOf(fileType), fileName + "【数据使用时间段:" + simpleDateFormat.format(planDto.getStartTime()) + "~" + simpleDateFormat.format(planDto.getEndTime()) + "】", stationCode));
+            }
 
+            for (BaseForecastEntity baseForecastEntity : list) {
+                List<PlanDto> planDtoList = planDtos.stream().filter(l -> l.isIn(baseForecastEntity)).collect(Collectors.toList());
+                if (planDtoList.size() > 0) {
+                    PlanDto planDto = planDtoList.get(0);
+                    baseForecastEntity.setCapacity(capacity);
+                    baseForecastEntity.setOpenCapacity(capacity.subtract(planDto.getOverhaulPlan().getOverhaulCapacity()));
+                    baseForecastEntity.setFpValue(baseForecastEntity.getFpValue().subtract(baseForecastEntity.getFpValue().multiply(planDto.getRadio())));
+                }else {
+                    baseForecastEntity.setOpenCapacity(capacity);
+                    baseForecastEntity.setCapacity(capacity);
 
+                }
+            }
+        }
+        overhaulPlanRecordsService.saveBatch(overhaulPlanRecordsList);
         return list;
     }
+
+
+    @Data
+    public class PlanDto {
+        private Date startTime;
+        private Date endTime;
+        private BigDecimal radio;
+        private OverhaulPlan overhaulPlan;
+
+        public Boolean isIn(BaseForecastEntity baseForecastEntity) {
+            if (baseForecastEntity.getTime().getTime() >= startTime.getTime() && baseForecastEntity.getTime().getTime() < endTime.getTime()) {
+                return true;
+            }
+            return false;
+        }
+        public PlanDto(Date startTime, Date endTime, OverhaulPlan overhaulPlan, BigDecimal capacity) {
+            this.startTime = startTime;
+            this.endTime = endTime;
+            this.overhaulPlan = overhaulPlan;
+            this.radio = BigDecimal.ONE.subtract(overhaulPlan.getOverhaulCapacity().divide(capacity,2, RoundingMode.HALF_UP));
+        }
+    }
+
 }

+ 49 - 19
cpp-admin/src/main/java/com/cpp/web/service/powerGeneation/impl/DayPowerGenerationServiceImpl.java

@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.common.utils.DateUtils;
 import com.cpp.web.domain.BaseCppEntity;
+import com.cpp.web.domain.accuracy.AccuracyPassRate;
 import com.cpp.web.domain.cloud.ForecastPowerShortTermCloud;
+import com.cpp.web.domain.enums.DataSourcesEnum;
 import com.cpp.web.domain.powerGeneration.DayPowerGeneration;
 import com.cpp.web.domain.station.ForecastPowerShortTermStation;
 import com.cpp.web.mapper.powerGeneration.DayPowerGenerationMapper;
+import com.cpp.web.service.accuracy.AccuracyPassRateService;
 import com.cpp.web.service.cloud.ForecastPowerShortTermCloudService;
 import com.cpp.web.service.powerGeneation.DayPowerGenerationService;
 import com.cpp.web.service.station.ForecastPowerShortTermStationService;
@@ -22,10 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -44,6 +45,8 @@ public class DayPowerGenerationServiceImpl extends ServiceImpl<DayPowerGeneratio
 
     private final ForecastPowerShortTermStationService forecastPowerShortTermStationService;
 
+    private final AccuracyPassRateService accuracyPassRateService;
+
     private final String dateFormat = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
 
     @Override
@@ -59,23 +62,50 @@ public class DayPowerGenerationServiceImpl extends ServiceImpl<DayPowerGeneratio
     }
 
     /**
-     *  发电量业务
+     * 发电量业务
+     *
      * @param stationCode
      */
     @Override
     public void generatePower(String stationCode) {
 
+        Date accuracyStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis() - 30 * 24 * 60 * 60 * 1000L);
+        Date accuracyEndTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis()  - 24 * 60 * 60 * 1000L);
+
+
+        String forecastModel = "";
+
+        // 查询近一个月内平均准确率高的预测模型
+        List<AccuracyPassRate> accuracyPassRateList = accuracyPassRateService.findByTimeBetweenAndStationCode(accuracyStartTime, accuracyEndTime, stationCode);
+
+        if (null != accuracyPassRateList && accuracyPassRateList.size() > 0) {
+            accuracyPassRateList = accuracyPassRateList.stream().filter(f -> !"无可用数据计算".equals(f.getAccuracy()) && !"无计算公式".equals(f.getAccuracy())).collect(Collectors.toList());
+            Function<String, Double> stringToDouble = s -> {
+                String numberStr = s.replace("%", "");
+                return Double.parseDouble(numberStr);
+            };
+            Map<String, Double> averageByCategory = accuracyPassRateList.stream()
+                    .collect(Collectors.groupingBy(
+                            AccuracyPassRate::getForecastModel,
+                            Collectors.averagingDouble(apr -> stringToDouble.apply(apr.getAccuracy()))
+                    ));
+            // 找出平均值最大的那一组
+            Optional<Map.Entry<String, Double>> maxAverageEntry = averageByCategory.entrySet().stream().max(Map.Entry.comparingByValue());
+            // 获取模型
+            forecastModel = maxAverageEntry.get().getKey();
+        }
+
         Date startTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis() + 24 * 60 * 60 * 1000L);
 
         Date endTime = DateTimeUtil.getDayLastTime(startTime.getTime() + 10 * 24 * 60 * 60 * 1000L - 1);
 
-        List<DayPowerGeneration> dayPowerGenerationList = findByGenDate(dateFormat,stationCode);
+        List<DayPowerGeneration> dayPowerGenerationList = findByGenDate(dateFormat, stationCode);
 
-        if (dayPowerGenerationList.size() > 0){
+        if (dayPowerGenerationList.size() > 0) {
             return;
         }
         // 云端预测
-        List<ForecastPowerShortTermCloud> forecastPowerShortTermCloudList = forecastPowerShortTermCloudService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
+        List<ForecastPowerShortTermCloud> forecastPowerShortTermCloudList = forecastPowerShortTermCloudService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode,"".equals(forecastModel)?"JY":forecastModel);
         // 站端预测
         List<ForecastPowerShortTermStation> forecastPowerShortTermStationList = forecastPowerShortTermStationService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
 
@@ -89,14 +119,14 @@ public class DayPowerGenerationServiceImpl extends ServiceImpl<DayPowerGeneratio
     @Override
     public List<DayPowerGeneration> findByStationCodeAndGenDateAndPredictionDataSource(String stationCode, String genDate, String predictionDataSource) {
         QueryWrapper<DayPowerGeneration> wrapper = new QueryWrapper<>();
-        if (null != stationCode && !"".equals(stationCode)){
-            wrapper.eq("station_code",stationCode);
+        if (null != stationCode && !"".equals(stationCode)) {
+            wrapper.eq("station_code", stationCode);
         }
-        if (null != genDate && !"".equals(genDate)){
-            wrapper.eq("gen_date",genDate);
+        if (null != genDate && !"".equals(genDate)) {
+            wrapper.eq("gen_date", genDate);
         }
-        if (null != predictionDataSource && !"".equals(predictionDataSource)){
-            wrapper.eq("prediction_data_source",predictionDataSource);
+        if (null != predictionDataSource && !"".equals(predictionDataSource)) {
+            wrapper.eq("prediction_data_source", predictionDataSource);
         }
         return list(wrapper);
     }
@@ -195,13 +225,13 @@ public class DayPowerGenerationServiceImpl extends ServiceImpl<DayPowerGeneratio
         return datas;
     }
 
-    public List<DayPowerGeneration> findByGenDate(String genDate,String stationCode){
+    public List<DayPowerGeneration> findByGenDate(String genDate, String stationCode) {
         QueryWrapper<DayPowerGeneration> wrapper = new QueryWrapper<>();
-        if (null != genDate && !"".equals(genDate)){
-            wrapper.eq("gen_date",genDate);
+        if (null != genDate && !"".equals(genDate)) {
+            wrapper.eq("gen_date", genDate);
         }
-        if (null != stationCode && !"".equals(stationCode)){
-            wrapper.eq("station_code",stationCode);
+        if (null != stationCode && !"".equals(stationCode)) {
+            wrapper.eq("station_code", stationCode);
         }
         return list(wrapper);
     }

+ 6 - 4
cpp-ui/src/views/statistics/analyzeRecords/index.vue

@@ -14,7 +14,7 @@
         />
       </el-form-item>
       <el-form-item label="场站名称">
-        <el-select v-model="stationCode" placeholder="请选择" style="width: 150px" popper-class="cpp-popper"
+        <el-select v-model="stationCode" placeholder="请选择" style="width: 150px" popper-class="cpp-popper" clearable
                    @change="changeStationCode">
           <el-option
             v-for="item in stationList"
@@ -82,6 +82,7 @@
         highlight-current-row
         show-overflow
         max-height="700"
+        :loading="loading"
         :data="tableData"
         :row-style="rowStyle">
         <vxe-table-column field="stationCode" title="场站名称" :formatter="codeChangeName"></vxe-table-column>
@@ -209,7 +210,9 @@ export default {
   },
   created() {
     this.getStationCode()
+    this.queryByStationCode()
     this.getDataSourcesEnum()
+    this.getAllFileType()
   },
   mounted() {
   },
@@ -265,9 +268,7 @@ export default {
           } else {
             this.fileType = this.windFileTypeList
           }
-          this.fileTypeName = this.fileType[0].value
-          this.queryByStationCode()
-          this.getAllFileType()
+          // this.fileTypeName = this.fileType[0].value
         })
       }else {
         this.fileType = this.allFileTypeList
@@ -279,6 +280,7 @@ export default {
       })
     },
     queryByStationCode() {
+      this.loading = true
       let startTime = Math.round(this.dateTime[0])
       let endTime = Math.round(this.dateTime[1])
       if (endTime <= startTime) {

+ 2 - 8
cpp-ui/src/views/statistics/predictedPowerGeneration/index.vue

@@ -42,6 +42,7 @@
             highlight-current-row
             show-overflow
             max-height="700"
+            :loading="loading"
             :data="tableData">
             <vxe-table-column field="time" title="预测日期"></vxe-table-column>
             <vxe-table-column field="forecastPowerGenerationZd" title="站端预测"></vxe-table-column>
@@ -124,6 +125,7 @@ export default {
         "predictionDataSource": this.predictionDataSource
       }
       this.$axios.get('/dayPowerGeneration/getList', {params: param}).then(response => {
+        this.loading = true
         this.tableData = response.data
         this.total = this.tableData.length
         this.loading = false
@@ -138,14 +140,6 @@ export default {
         this.contrastDraw(times, zd, yd)
       })
     },
-    codeChangeName(row) {
-      var codeList = this.stationList
-      for (let i = 0; i < codeList.length; i++) {
-        if (row.cellValue == codeList[i].value) {
-          return codeList[i].label
-        }
-      }
-    },
     contrastDraw(times, zd, yd) {
       this.contrastChart = echarts.init(document.getElementById('contrastCharts'), "dark", {renderer: 'svg'})
 

+ 3 - 1
cpp-ui/src/views/statistics/reportData/index.vue

@@ -51,6 +51,7 @@
         highlight-current-row
         show-overflow
         max-height="700"
+        :loading="loading"
         :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
         :row-style="rowStyle">
         <vxe-table-column field="stationCode" title="场站名称" :formatter="codeChangeName"></vxe-table-column>
@@ -198,11 +199,12 @@ export default {
             label: '运行信息'
           }]
         }
-        this.fileTypeName = this.fileType[0].value
+        // this.fileTypeName = this.fileType[0].value
         this.queryByStationCode()
       })
     },
     queryByStationCode() {
+      this.loading = true
       let startTime = Math.round(this.dateTime[0])
       let endTime = Math.round(this.dateTime[1])
       if (endTime <= startTime) {