Przeglądaj źródła

优化查询,新增限电统计查询

fanxiaoyu 6 miesięcy temu
rodzic
commit
21bdb235a6

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

@@ -3,6 +3,7 @@ package com.cpp.web.controller.configManager;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cpp.common.core.domain.R;
 import com.cpp.web.service.datafactory.ParsingLogService;
+import com.cpp.web.service.station.ElectricFieldService;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,14 +13,18 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/parsingLog")
 public class ParsingLogController {
-    @Autowired
-    ParsingLogService parsingLogService;
+
+    private final ParsingLogService parsingLogService;
+
+    private final ElectricFieldService electricFieldService;
 
     /**
      * 根据场站编号 解析时间 文件状态 分页查询
@@ -42,8 +47,14 @@ public class ParsingLogController {
     @ApiOperation(value = "根据场站编号分页查询", notes = "分页查询")
     @GetMapping("/getByStationCodeAndCreateTimeAndFileType")
     public R getByStationCodeAndCreateTimeAndFileType(Long page, Long size, String stationCode, Long startTime,Long endTime, String fileType,String dataSources,String parsingDescribe,String parsingFileStatus) {
+        Map<String,Object> map = new HashMap<>();
+        String electricFieldType = electricFieldService.findByStationCode(stationCode).getElectricFieldTypeEnum();
+
         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)));
+        map.put("data",parsingLogService.page(pages, parsingLogService.getByStationCodeAndCreateTimeAndFileType(stationCode, new Date(startTime), new Date(endTime), fileType,dataSources,parsingDescribe,parsingFileStatus)));
+        map.put("type",electricFieldType);
+//        return R.ok(parsingLogService.page(pages, parsingLogService.getByStationCodeAndCreateTimeAndFileType(stationCode, new Date(startTime), new Date(endTime), fileType,dataSources,parsingDescribe,parsingFileStatus)));
+        return R.ok(map);
     }
 }

+ 25 - 0
cpp-admin/src/main/java/com/cpp/web/controller/electricityRestriction/electricityRestrictionController.java

@@ -0,0 +1,25 @@
+package com.cpp.web.controller.electricityRestriction;
+
+import com.cpp.common.core.domain.R;
+import com.cpp.web.service.electricityRestriction.ElectricityRestrictionService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+
+/**
+ * 限电统计查询控制层
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("electricityRestriction")
+public class electricityRestrictionController {
+
+    private final ElectricityRestrictionService electricityRestrictionService;
+    @GetMapping("/getData")
+    public R getData(Long startTime,Long endTime,String stationCode){
+        return R.ok(electricityRestrictionService.getElectricityRestriction(new Date(startTime),new Date(endTime),stationCode));
+    }
+}

+ 68 - 55
cpp-admin/src/main/java/com/cpp/web/controller/reportData/ReportDataController.java

@@ -56,28 +56,16 @@ public class ReportDataController {
     @GetMapping("/getData")
     public R getData(String stationCode, String fileType, Long startTime, Long endTime) {
 
-        // 获取场站类型
-        ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+        Map<String,Object> map = new HashMap<>();
 
-        String electricFieldTypeEnum = electricField.getElectricFieldTypeEnum();
+        String electricFieldType = electricFieldService.findByStationCode(stationCode).getElectricFieldTypeEnum();
 
-        List<FileTypeEnum> fileTypeEnumList = new ArrayList<>();
         List<ParsingLog> resultList = new ArrayList<>();
 
-        if (null == fileType) {
-            if (electricFieldTypeEnum.equals("E1")) {
-                fileTypeEnumList = FileTypeEnum.getPhotovoltaicFileType();
-            } else {
-                fileTypeEnumList = FileTypeEnum.getWindFileType();
-            }
-            List<ParsingLog> parsingLogList = new ArrayList<>();
-            for (FileTypeEnum fileTypeEnum : fileTypeEnumList) {
-                parsingLogList = getAllFileName(fileTypeEnum.name(), startTime, endTime, stationCode);
-                resultList.addAll(parsingLogList);
-            }
-        } else {
-            resultList = getAllFileName(fileType, startTime, endTime, stationCode);
-        }
+        if (null == fileType)
+            fileType = "";
+
+        resultList.addAll(getAllFileName(fileType, startTime, endTime, stationCode));
 
         // 定义比较器
         Comparator<ParsingLog> timestampComparator = new Comparator<ParsingLog>() {
@@ -94,7 +82,9 @@ public class ReportDataController {
         };
         // 排序
         Collections.sort(resultList, timestampComparator);
-        return R.ok(resultList);
+        map.put("data",resultList);
+        map.put("type",electricFieldType);
+        return R.ok(map);
     }
 
     /**
@@ -119,52 +109,75 @@ public class ReportDataController {
         List<ParsingLog> resultList = new ArrayList<>();
         String rCdqKey = iSysConfigService.selectConfigByKey("sync_regulation");
         // 获取应上报文件名
-        List<String> shouldFileName = reportDataService.shouldFileName(fileType, startTime, endTime, stationCode,rCdqKey);
+//        List<String> shouldFileName = reportDataService.shouldFileName(fileType, startTime, endTime, rCdqKey);
+        Map<String, List<String>> map = reportDataService.getFileResults(fileType, startTime, endTime, stationCode);
         List<ParsingLog> parsingLogList = parsingLogService.findByTimeBetweenAndFileTypeAndStationCode(new Date(startTime), new Date(endTime), fileType, stationCode);
+        if ("".equals(rCdqKey) || "true".equals(rCdqKey)) {
+            map.remove("rcdq");
+        }
         if (parsingLogList.size() > 0) {
             resultList.addAll(parsingLogList);
-            for (String s : shouldFileName) {
-                List<ParsingLog> collectList = parsingLogList.stream().filter(f -> f.getFileName().contains(s)).collect(Collectors.toList());
-                if (collectList.size() == 0) {
-                    ParsingLog parsingLogs = new ParsingLog();
-
-                    if ("rdq".equals(fileType) || "dq".equals(fileType) || "nwp".equals(fileType)) {
-                        parsingLogs.setFileName("sign_" + s + "_0000_" + fileType.toUpperCase() + ".WPD");
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                for (String item : entry.getValue()) {
+                    List<ParsingLog> collectList = parsingLogList.stream().filter(f -> f.getFileName().contains(item) && f.getFileType().equals(FileTypeEnum.valueOf(entry.getKey()))//
+                    ).collect(Collectors.toList());
+                    if (collectList.size() == 0) {
+                        resultList.add(collectRecords(entry.getKey(), rCdqKey, stationCode, item));
                     }
-                    if (!rCdqKey.equals("true")){
-                        if ("rcdq".equals(fileType) || "cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
-                            parsingLogs.setFileName("sign_" + s + "_" + fileType.toUpperCase() + ".WPD");
-                        }
-                    }else {
-                        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_" + s + "_" + fileType.toUpperCase() + ".WPD");
-                        }
-                    }
-
-                    parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
-                    parsingLogs.setParsingFileStatus("失败");
-                    parsingLogs.setStationCode(stationCode);
-                    parsingLogs.setDataSources(DataSourcesEnum.E1);
-                    resultList.add(parsingLogs);
-
                 }
             }
-        } else {
-            for (int i = 0; i < shouldFileName.size(); i++) {
-                ParsingLog parsingLogs = new ParsingLog();
-                if ("rdq".equals(fileType) || "dq".equals(fileType) || "nwp".equals(fileType)) {
-                    parsingLogs.setFileName("sign_" + shouldFileName.get(i) + "_0000_" + fileType.toUpperCase() + ".WPD");
+        } else if ("".equals(fileType)) {
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                List<String> value = entry.getValue();
+                for (String item : value) {
+                    resultList.add(collectRecords(entry.getKey(), rCdqKey, stationCode, item));
                 }
-                if ("rcdq".equals(fileType) || "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");
+            }
+        } else {
+            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
+                List<String> value = entry.getValue();
+                for (String item : value) {
+                    resultList.add(collectRecords(fileType, rCdqKey, stationCode, item));
                 }
-                parsingLogs.setParsingFileStatus("失败");
-                parsingLogs.setStationCode(stationCode);
-                parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
-                parsingLogs.setDataSources(DataSourcesEnum.E1);
-                resultList.add(parsingLogs);
             }
+            resultList = resultList.stream().filter(f -> f.getFileType().name().equals(FileTypeEnum.valueOf(fileType))).collect(Collectors.toList());
+
         }
+
         return resultList;
+
+    }
+
+    /**
+     * 拼接未上报文件名
+     *
+     * @param fileType
+     * @param rCdqKey
+     * @param stationCode
+     * @param str
+     * @return
+     */
+    public ParsingLog collectRecords(String fileType, String rCdqKey, String stationCode, String str) {
+        ParsingLog parsingLogs = new ParsingLog();
+
+        List<String> rdqTypes = Arrays.asList("rdq", "dq", "nwp");
+        List<String> rcdqTypes = Arrays.asList("rcdq", "cdq", "status", "nbq", "qxz", "rp", "fj", "cft");
+
+        if (rdqTypes.contains(fileType)) {
+            parsingLogs.setFileName("sign_" + str + "_0000_" + fileType.toUpperCase() + ".WPD");
+        } else if (!"true".equals(rCdqKey) && !"".equals(rCdqKey)) {
+            if (rcdqTypes.contains(fileType)) {
+                parsingLogs.setFileName("sign_" + str + "_" + fileType.toUpperCase() + ".WPD");
+            }
+        } else if (rcdqTypes.stream().filter(t -> !"rcdq".equals(t)).collect(Collectors.toList()).contains(fileType)) {
+            parsingLogs.setFileName("sign_" + str + "_" + fileType.toUpperCase() + ".WPD");
+        }
+
+        parsingLogs.setFileType(FileTypeEnum.valueOf(fileType));
+        parsingLogs.setParsingFileStatus("失败");
+        parsingLogs.setStationCode(stationCode);
+        parsingLogs.setDataSources(DataSourcesEnum.E1);
+
+        return parsingLogs;
     }
 }

+ 33 - 11
cpp-admin/src/main/java/com/cpp/web/controller/tool/EnumSelectController.java

@@ -5,9 +5,11 @@ import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
 import com.cpp.web.domain.datafactory.enums.UseStatusEnum;
 import com.cpp.web.domain.enums.AlarmEnum;
 import com.cpp.web.domain.enums.DataSourcesEnum;
+import com.cpp.web.domain.station.ElectricField;
 import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
 import com.cpp.web.domain.station.enums.EquipmentTypeEnum;
 import com.cpp.web.domain.station.enums.ProvinceEnum;
+import com.cpp.web.service.station.ElectricFieldService;
 import lombok.Data;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -15,7 +17,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 枚举返回select类型选择转换接口
@@ -25,9 +29,11 @@ import java.util.List;
 @RequestMapping("enumSelect")
 public class EnumSelectController {
 
+    private final ElectricFieldService electricFieldService;
 
     /**
      * 告警类型
+     *
      * @return
      */
     @GetMapping("/alarmEnum")
@@ -35,9 +41,9 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (AlarmEnum value : AlarmEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
-        
+
         return R.ok(list);
     }
 
@@ -47,7 +53,7 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (DataSourcesEnum value : DataSourcesEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
@@ -58,19 +64,35 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (FileTypeEnum value : FileTypeEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
     }
 
+    @GetMapping("/allUseFileType")
+    public R fileTypeEnumByStationCode() {
+        List<EnumSelect> listSolar = new ArrayList<>();
+        List<EnumSelect> listWind = new ArrayList<>();
+        Map<String, List<EnumSelect>> map = new HashMap<>();
+        for (FileTypeEnum value : FileTypeEnum.getPhotovoltaicFileType()) {
+            listSolar.add(new EnumSelect(value.getMessage(), value.name()));
+        }
+        map.put("solar", listSolar);
+        for (FileTypeEnum value : FileTypeEnum.getWindFileType()) {
+            listWind.add(new EnumSelect(value.getMessage(), value.name()));
+        }
+        map.put("wind", listWind);
+        return R.ok(map);
+    }
+
 
     @GetMapping("/useStatusEnum")
     public R useStatusEnum() {
 
         List<EnumSelect> list = new ArrayList<>();
         for (UseStatusEnum value : UseStatusEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
@@ -82,7 +104,7 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (ElectricFieldTypeEnum value : ElectricFieldTypeEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
@@ -94,7 +116,7 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (EquipmentTypeEnum value : EquipmentTypeEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
@@ -106,15 +128,15 @@ public class EnumSelectController {
 
         List<EnumSelect> list = new ArrayList<>();
         for (ProvinceEnum value : ProvinceEnum.values()) {
-            list.add(new EnumSelect(value.getMessage(),value.name()));
+            list.add(new EnumSelect(value.getMessage(), value.name()));
         }
 
         return R.ok(list);
     }
-    
-    
+
+
     @Data
-    public class EnumSelect{
+    public class EnumSelect {
         private String label;
         private String value;
 

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

@@ -57,6 +57,7 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
         }
         wrapper.eq("data_sources","E2");
         wrapper.eq("forecast_how_long_ago",1);
+        wrapper.eq("forecast_type","dq");
         return list(wrapper);
     }
 }

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

@@ -93,8 +93,7 @@ public class ParsingLogServiceImpl extends ServiceImpl<ParsingLogMapper, Parsing
             wrapper.eq("file_type", fileType);
         }
         wrapper.eq("data_sources", "E1");
-        List<ParsingLog> parsingLogs = parsingLogMapper.selectList(wrapper);
-        return parsingLogs;
+        return list(wrapper);
     }
 
     @Override

+ 10 - 0
cpp-admin/src/main/java/com/cpp/web/service/electricityRestriction/ElectricityRestrictionService.java

@@ -0,0 +1,10 @@
+package com.cpp.web.service.electricityRestriction;
+
+
+import java.util.Date;
+import java.util.List;
+
+public interface ElectricityRestrictionService {
+
+    List getElectricityRestriction(Date startTime,Date endTime,String stationCode);
+}

+ 133 - 0
cpp-admin/src/main/java/com/cpp/web/service/electricityRestriction/impl/ElectricityRestrictionServiceImpl.java

@@ -0,0 +1,133 @@
+package com.cpp.web.service.electricityRestriction.impl;
+
+import com.cpp.web.domain.station.ElectricField;
+import com.cpp.web.domain.station.PowerStationStatusData;
+import com.cpp.web.service.electricityRestriction.ElectricityRestrictionService;
+import com.cpp.web.service.station.ElectricFieldService;
+import com.cpp.web.service.station.PowerStationStatusDataService;
+import com.cpp.web.utils.DateTimeUtil;
+import lombok.Data;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+@Service
+@RequiredArgsConstructor
+public class ElectricityRestrictionServiceImpl implements ElectricityRestrictionService {
+
+    private final PowerStationStatusDataService powerStationStatusDataService;
+
+    private final ElectricFieldService electricFieldService;
+
+    private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+    private final static SimpleDateFormat formatDate = new SimpleDateFormat("HH:mm");
+
+    @Override
+    public List getElectricityRestriction(Date startTime, Date endTime, String stationCode) {
+        List<ElectricField> electricFieldList;
+        List<ElectricityRestrictionDto> list = new ArrayList<>();
+        List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.findByTimeBetweenAndStationCode(startTime, endTime, stationCode);
+
+        if (null == stationCode) {
+            electricFieldList = electricFieldService.list();
+            for (ElectricField electricField : electricFieldList) {
+                List<PowerStationStatusData> collectList = powerStationStatusDataList.stream().filter(f -> f.getPowerRationing() == 1 && f.getStationCode().equals(electricField.getStationCode())).collect(Collectors.toList());
+                list.addAll(get(collectList, startTime, endTime, electricField.getStationCode()));
+            }
+        } else {
+            powerStationStatusDataList = powerStationStatusDataList.stream().filter(f -> f.getPowerRationing() == 1).collect(Collectors.toList());
+            list = get(powerStationStatusDataList, startTime, endTime, stationCode);
+        }
+        return list;
+    }
+
+    /**
+     * 获取相关所需
+     *
+     * @param powerStationStatusDataList
+     * @param startTime
+     * @param endTime
+     * @param stationCode
+     * @return
+     */
+    public List<ElectricityRestrictionDto> get(List<PowerStationStatusData> powerStationStatusDataList, Date startTime, Date endTime, String stationCode) {
+        List<ElectricityRestrictionDto> list = new ArrayList<>();
+        if (null != powerStationStatusDataList && powerStationStatusDataList.size() > 0) {
+            List<String> dayList = DateTimeUtil.getDatesInRange(startTime, endTime);
+            for (String s : dayList) {
+                List<PowerStationStatusData> collectList = powerStationStatusDataList.stream().filter(f -> dateFormat.format(f.getTime()).equals(s)).collect(Collectors.toList());
+                if (collectList.size() > 0) {
+                    ElectricityRestrictionDto electricityRestrictionDto = new ElectricityRestrictionDto();
+                    // 总限电量
+                    BigDecimal totalPowerLimit = collectList.stream().map(PowerStationStatusData::getBlockedCapacity).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
+                    electricityRestrictionDto.setTime(s);
+                    electricityRestrictionDto.setTotalPowerLimit(totalPowerLimit.divide(new BigDecimal(12), 2, RoundingMode.HALF_UP));
+                    // 限电时长
+                    electricityRestrictionDto.setDuration(new BigDecimal(collectList.size()).divide(new BigDecimal(12), 2, RoundingMode.HALF_UP).doubleValue());
+                    electricityRestrictionDto.setTimeSlot(mergeTime(collectList));
+                    electricityRestrictionDto.setStationCode(stationCode);
+                    list.add(electricityRestrictionDto);
+                }
+            }
+        }
+        return list;
+    }
+
+
+    /**
+     * 合并时间段
+     *
+     * @param list
+     * @return
+     */
+    public String mergeTime(List<PowerStationStatusData> list) {
+        // 检查并拼接连续的日期
+        StringBuilder result = new StringBuilder();
+        Date prevDate = null;
+        for (int i = 0; i < list.size(); i++) {
+            Date finalTime = list.get(i).getTime();
+            if (null == prevDate) {
+                prevDate = finalTime;
+                result.append(formatDate.format(finalTime) + "~");
+            } else {
+                if (DateTimeUtil.isMinutesDifference(finalTime, prevDate, 5L)) {
+                    prevDate = finalTime;
+                    if (i == list.size() - 1) {
+                        result.append(formatDate.format(finalTime) + ";");
+                    }
+                } else if (i == list.size() - 1) {
+                    result.append(formatDate.format(list.get(i - 1).getTime()) + ";").append(formatDate.format(finalTime) + "~").append(formatDate.format(finalTime) + ";");
+                    prevDate = finalTime;
+                } else {
+                    result.append(formatDate.format(list.get(i - 1).getTime()) + ";").append(formatDate.format(finalTime) + "~");
+                    prevDate = finalTime;
+                }
+            }
+        }
+        return result.toString();
+    }
+
+
+    @Data
+    public class ElectricityRestrictionDto {
+        // 日期
+        private String time;
+        // 时间段
+        private String timeSlot;
+        // 限电时长
+        private Double duration;
+        // 总限电量
+        private BigDecimal totalPowerLimit;
+        // 场站编号
+        private String stationCode;
+    }
+}

+ 4 - 1
cpp-admin/src/main/java/com/cpp/web/service/reprtdata/ReportDataService.java

@@ -1,6 +1,7 @@
 package com.cpp.web.service.reprtdata;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ReportDataService {
 
@@ -8,5 +9,7 @@ public interface ReportDataService {
     int shouldFileNum(String fileType,Long startTime,Long endTime,String stationCode);
 
 
-    List<String> shouldFileName(String fileType,Long startTime,Long endTime,String stationCode,String key);
+    List<String> shouldFileName(String fileType,Long startTime,Long endTime,String key);
+
+    Map<String, List<String>> getFileResults(String fileType, long startTime, long endTime,String stationCode);
 }

+ 52 - 10
cpp-admin/src/main/java/com/cpp/web/service/reprtdata/impl/ReportDataServiceImpl.java

@@ -1,7 +1,9 @@
 package com.cpp.web.service.reprtdata.impl;
 
-import com.cpp.system.service.ISysConfigService;
+import com.cpp.common.utils.spring.SpringUtils;
+import com.cpp.web.domain.station.ElectricField;
 import com.cpp.web.service.reprtdata.ReportDataService;
+import com.cpp.web.service.station.ElectricFieldService;
 import com.cpp.web.utils.DateTimeUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -12,15 +14,13 @@ import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @Service
 @RequiredArgsConstructor
 @Slf4j
 public class ReportDataServiceImpl implements ReportDataService {
+
     // 当前文件类型应上报文件个数
     @Override
     public int shouldFileNum(String fileType, Long startTime, Long endTime, String stationCode) {
@@ -36,13 +36,13 @@ public class ReportDataServiceImpl implements ReportDataService {
     }
 
     @Override
-    public List<String> shouldFileName(String fileType, Long startTime, Long endTime, String stationCode,String key) {
+    public List<String> shouldFileName(String fileType, Long startTime, Long endTime, String key) {
 
         List<String> list = new ArrayList<>();
         if ("rdq".equals(fileType) || "dq".equals(fileType) || "nwp".equals(fileType)) {
             list = getDatesInRange(startTime + 24 * 60 * 60 * 1000L, endTime + 24 * 60 * 60 * 1000L);
         }
-        if (!key.equals("true")){
+        if (!"".equals(key) && !key.equals("true")) {
             if ("rcdq".equals(fileType) || "cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
                 if (new Date(endTime).after(new Date())) {
                     list = getMin(startTime, new Date().getTime(), fileType);
@@ -50,7 +50,7 @@ public class ReportDataServiceImpl implements ReportDataService {
                     list = getMin(startTime, endTime, fileType);
                 }
             }
-        }else {
+        } else {
             if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
                 if (new Date(endTime).after(new Date())) {
                     list = getMin(startTime, new Date().getTime(), fileType);
@@ -63,6 +63,48 @@ public class ReportDataServiceImpl implements ReportDataService {
         return list;
     }
 
+    @Override
+    public Map<String, List<String>> getFileResults(String fileType, long startTime, long endTime, String stationCode) {
+
+        Long calculateStartTime = startTime + 24 * 60 * 60 * 1000L;
+        Long calculateEndTime = endTime + 24 * 60 * 60 * 1000L;
+        Map<String, List<String>> resultMap = new HashMap<>();
+
+        ElectricField electricField = SpringUtils.getBean(ElectricFieldService.class).findByStationCode(stationCode);
+        String typeE = electricField.getElectricFieldTypeEnum();
+        Set<String> fileTypes = new HashSet<>();
+        if (typeE.equals("E1")) {
+            fileTypes = new HashSet<>(Arrays.asList("rcdq", "cdq", "status", "nbq", "qxz", "rp"));
+        } else {
+            fileTypes = new HashSet<>(Arrays.asList("rcdq", "cdq", "status", "rp", "fj", "cft"));
+        }
+        if ("".equals(fileType)) {
+            resultMap.put("rdq", getDatesInRange(calculateStartTime, calculateEndTime));
+            resultMap.put("dq", getDatesInRange(calculateStartTime, calculateEndTime));
+            resultMap.put("nwp", getDatesInRange(calculateStartTime, calculateEndTime));
+            for (String type : fileTypes) {
+                List<String> results = (new Date(System.currentTimeMillis()).after(new Date()))
+                        ? getMin(startTime, new Date().getTime(), type)
+                        : getMin(startTime, System.currentTimeMillis(), type);
+
+                resultMap.put(type, results);
+            }
+        } else {
+            if ("rdq".equals(fileType) || "dq".equals(fileType) || "nwp".equals(fileType)) {
+                resultMap.put(fileType, getDatesInRange(calculateStartTime, calculateEndTime));
+            }
+            if ("cdq".equals(fileType) || "status".equals(fileType) || "nbq".equals(fileType) || "qxz".equals(fileType) || "rp".equals(fileType) || "fj".equals(fileType) || "cft".equals(fileType)) {
+                if (new Date(endTime).after(new Date())) {
+                    resultMap.put(fileType, getMin(startTime, new Date().getTime(), fileType));
+                } else {
+                    resultMap.put(fileType, getMin(startTime, endTime, fileType));
+                }
+            }
+        }
+
+        return resultMap;
+    }
+
     /**
      * 获取每一天 判断dq和nwp
      *
@@ -98,7 +140,7 @@ public class ReportDataServiceImpl implements ReportDataService {
      */
     public List<String> getMin(Long startTime, Long endTime, String fileType) {
         List<String> list = new ArrayList<>();
-        if ("cdq".equals(fileType)|| "rcdq".equals(fileType)){
+        if ("cdq".equals(fileType) || "rcdq".equals(fileType)) {
             startTime = startTime + 15 * 60 * 1000L;
         }
         LocalDateTime start = LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault());
@@ -107,7 +149,7 @@ public class ReportDataServiceImpl implements ReportDataService {
         LocalDateTime currentTime = start;
         while (!currentTime.isAfter(end)) {
             String formattedTime = currentTime.format(formatter);
-            if ("cdq".equals(fileType) || "rcdq".equals(fileType)|| "status".equals(fileType)) {
+            if ("cdq".equals(fileType) || "rcdq".equals(fileType) || "status".equals(fileType)) {
                 currentTime = currentTime.plusMinutes(15);
             } else {
                 currentTime = currentTime.plusMinutes(5);

+ 55 - 0
cpp-admin/src/main/java/com/cpp/web/utils/DateTimeUtil.java

@@ -449,4 +449,59 @@ public class DateTimeUtil {
         return (int) ((dateTime - DateTimeUtil.getDayStartTime(dateTime).getTime()) / (interval)) + 1;
     }
 
+    /**
+     *  获取每一天
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+
+    public static List<String> getDatesInRange(Date startDate, Date endDate) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        List<String> dateList = new ArrayList<>();
+        Calendar startCalendar = Calendar.getInstance();
+        Calendar endCalendar = Calendar.getInstance();
+
+        startCalendar.setTime(startDate);
+        endCalendar.setTime(endDate);
+
+        endCalendar.add(Calendar.DAY_OF_YEAR, 1);
+        endCalendar.set(Calendar.HOUR_OF_DAY, 0);
+        endCalendar.set(Calendar.MINUTE, 0);
+        endCalendar.set(Calendar.SECOND, 0);
+        endCalendar.set(Calendar.MILLISECOND, 0);
+
+        while (!startCalendar.after(endCalendar)) {
+            dateList.add(simpleDateFormat.format(startCalendar.getTime()));
+            startCalendar.add(Calendar.DAY_OF_YEAR, 1);
+        }
+
+        return dateList;
+    }
+
+    /**
+     *  判断两个时间相差分钟数
+     * @param date1
+     * @param date2
+     * @param size
+     * @return
+     */
+    public static boolean isMinutesDifference(Date date1, Date date2,Long size) {
+
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(date1);
+
+        Calendar calendar2 = Calendar.getInstance();
+        calendar2.setTime(date2);
+
+        long millis1 = calendar1.getTimeInMillis();
+        long millis2 = calendar2.getTimeInMillis();
+
+        long diffInMillis = Math.abs(millis1 - millis2);
+
+        long fiveMinutesInMillis = size * 60 * 1000;
+
+        // 判断时间差是否等于5分钟
+        return diffInMillis == fiveMinutesInMillis;
+    }
 }

+ 2 - 3
cpp-ui/package.json

@@ -40,7 +40,7 @@
     "axios": "0.28.1",
     "clipboard": "2.0.8",
     "core-js": "3.37.1",
-    "echarts": "5.4.0",
+    "echarts": "^5.3.1",
     "element-ui": "2.15.14",
     "file-saver": "2.0.5",
     "fuse.js": "6.4.3",
@@ -60,8 +60,7 @@
     "vuedraggable": "2.24.3",
     "vuex": "3.6.0",
     "vxe-table": "^2.11.0",
-    "xe-utils": "^3.5.30",
-    "echarts": "^5.3.1"
+    "xe-utils": "^3.5.30"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "4.4.6",

+ 25 - 86
cpp-ui/src/views/statistics/analyzeRecords/index.vue

@@ -14,8 +14,7 @@
         />
       </el-form-item>
       <el-form-item label="场站名称">
-        <el-select v-model="stationCode" placeholder="请选择" style="width: 150px" popper-class="cpp-popper" clearable
-                   @change="changeStationCode">
+        <el-select v-model="stationCode" placeholder="请选择" style="width: 150px" popper-class="cpp-popper" clearable>
           <el-option
             v-for="item in stationList"
             :key="item.value"
@@ -149,77 +148,27 @@ export default {
       tableData: [],
       loading: false,
       electricFieldTypeEnum: '',
-      windFileTypeList: [{
-        value: 'dq',
-        label: '短期'
-      }, {
-        value: 'rdq',
-        label: '调控后短期'
-      }, {
-        value: 'cdq',
-        label: '超短期'
-      }, {
-        value: 'rcdq',
-        label: '调控后超短期'
-      }, {
-        value: 'nwp',
-        label: 'Nwp'
-      }, {
-        value: 'cft',
-        label: '测风塔'
-      }, {
-        value: 'fj',
-        label: '风机'
-      }, {
-        value: 'rp',
-        label: '实发功率'
-      }, {
-        value: 'status',
-        label: '运行信息'
-      }],
-      photovoltaicFileTypeList: [{
-        value: 'dq',
-        label: '短期'
-      }, {
-        value: 'rdq',
-        label: '调控后短期'
-      }, {
-        value: 'cdq',
-        label: '超短期'
-      }, {
-        value: 'rcdq',
-        label: '调控后超短期'
-      }, {
-        value: 'nwp',
-        label: 'Nwp'
-      }, {
-        value: 'qxz',
-        label: '气象站'
-      }, {
-        value: 'nbq',
-        label: '逆变器'
-      }, {
-        value: 'rp',
-        label: '实发功率'
-      }, {
-        value: 'status',
-        label: '运行信息'
-      }],
+      windFileTypeList: [],
+      photovoltaicFileTypeList: [],
       allFileTypeList: []
     }
   },
   created() {
-    this.getStationCode()
-    this.queryByStationCode()
     this.getDataSourcesEnum()
     this.getAllFileType()
+    this.getFileTypeInfo()
+
   },
   mounted() {
   },
   computed: {},
   methods: {
-    changeStationCode() {
-      this.getElectricFieldTypeEnum()
+    getFileTypeInfo() {
+      this.$axios.get('/enumSelect/allUseFileType').then(response => {
+        this.photovoltaicFileTypeList = response.data.solar
+        this.windFileTypeList = response.data.wind
+        this.getStationCode()
+      })
     },
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
@@ -251,31 +200,12 @@ export default {
         this.stationList.push({value: '未知', label: '未知'})
         if (this.stationList.length > 0) {
           this.stationCode = this.stationList[0].value
-          this.getElectricFieldTypeEnum()
+          this.queryByStationCode()
         }
       })
     },
-    getElectricFieldTypeEnum() {
-      this.loading = true
-      const param = {
-        "stationCode": this.stationCode,
-      }
-      if (this.stationCode != '未知'){
-        this.$axios.get('reportData/getElectricFieldTypeEnum', {params: param}).then(response => {
-          this.electricFieldTypeEnum = response.data
-          if (this.electricFieldTypeEnum === 'E1') {
-            this.fileType = this.photovoltaicFileTypeList
-          } else {
-            this.fileType = this.windFileTypeList
-          }
-          // this.fileTypeName = this.fileType[0].value
-        })
-      }else {
-        this.fileType = this.allFileTypeList
-      }
-    },
-    getAllFileType(){
-      this.$axios.get('enumSelect/fileTypeEnum').then(response =>{
+    getAllFileType() {
+      this.$axios.get('enumSelect/fileTypeEnum').then(response => {
         this.allFileTypeList = response.data
       })
     },
@@ -299,8 +229,17 @@ export default {
         "page": this.currentPage
       }
       this.$axios.get('/parsingLog/getByStationCodeAndCreateTimeAndFileType', {params: param}).then(response => {
-        this.tableData = response.data.records
-        this.total = response.data.total
+        this.tableData = response.data.data.records
+        this.total = response.data.data.total
+        if (this.stationCode != '未知') {
+          if (response.data.type === 'E1') {
+            this.fileType = this.photovoltaicFileTypeList
+          } else {
+            this.fileType = this.windFileTypeList
+          }
+        } else {
+          this.fileType = this.allFileTypeList
+        }
         this.loading = false
       })
     },

+ 141 - 0
cpp-ui/src/views/statistics/electricityRestriction/index.vue

@@ -0,0 +1,141 @@
+<template>
+  <div class="app-container">
+    <el-form :inline="true" size="small" class="dark-el-input dark-el-button">
+      <el-form-item label="时间">
+        <el-date-picker
+          :clearable="false"
+          v-model="dateTime"
+          type="datetimerange"
+          range-separator="至"
+          start-placeholder="开始日期"
+          end-placeholder="结束日期"
+          :default-time="['00:00:00', '23:59:59']"
+          popper-class="cpp-popper"
+        />
+      </el-form-item>
+      <el-form-item label="场站名称">
+        <el-select v-model="stationCode" placeholder="请选择" style="width: 255px" popper-class="cpp-popper" clearable @change="changStationCode">
+          <el-option
+            v-for="item in stationList"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value">
+          </el-option>
+        </el-select>
+      </el-form-item>
+
+      <el-form-item>
+        <el-button type="primary" size="mini" style="margin-left: 5px" icon="el-icon-search"
+                   @click="queryByStationCode">查询
+        </el-button>
+      </el-form-item>
+    </el-form>
+    <div style="padding-top: 10px">
+      <vxe-table
+        ref="xTable"
+        align="center"
+        class="mytable-style"
+        auto-resize
+        border
+        resizable
+        export-config
+        highlight-current-row
+        show-overflow
+        max-height="700"
+        :loading="loading"
+        :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
+      >
+        <vxe-table-column field="stationCode" title="场站名称" :formatter="codeChangeName"></vxe-table-column>
+        <vxe-table-column field="time" title="日期"></vxe-table-column>
+        <vxe-table-column field="timeSlot" title="限电时间段"></vxe-table-column>
+        <vxe-table-column field="duration" title="限电时长(h)"></vxe-table-column>
+        <vxe-table-column field="totalPowerLimit" title="总限电量(MWh)"></vxe-table-column>
+      </vxe-table>
+      <vxe-pager
+        background
+        :loading="loading"
+        :current-page.sync="currentPage"
+        :page-size.sync="pageSize"
+        :total="total"
+        @page-change="handlePageChange"
+        :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
+      </vxe-pager>
+    </div>
+  </div>
+</template>
+
+
+<script>
+export default {
+  name: 'electricityRestriction',
+  data() {
+    return {
+      dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1],
+      title: "",
+      total: 0,
+      pageSize: 10,
+      currentPage: 1,
+      stationList: [],
+      stationCode: null,
+      stationName: undefined,
+      tableData: [],
+      loading: false,
+      electricFieldTypeEnum: '',
+    }
+  },
+  created() {
+    this.queryByStationCode()
+    this.getStationCode()
+  },
+  mounted() {
+  },
+  computed: {},
+  methods: {
+    changStationCode(){
+      this.getElectricFieldTypeEnum()
+    },
+    handlePageChange({currentPage, pageSize}) {
+      this.currentPage = currentPage
+      if (this.pageSize != pageSize) {
+        this.changePageSize(pageSize)
+      }
+      this.pageSize = pageSize
+    },
+    getStationCode() {
+      this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
+        this.stationList = response.data
+      })
+    },
+    queryByStationCode() {
+      this.loading = true
+      let startTime = Math.round(this.dateTime[0])
+      let endTime = Math.round(this.dateTime[1])
+      if (endTime <= startTime) {
+        this.$message.warning("开始时间不能大于结束时间")
+        return
+      }
+      const param = {
+        "stationCode": this.stationCode,
+        "startTime": startTime,
+        "endTime": endTime,
+      }
+      this.$axios.get('/electricityRestriction/getData', {params: param}).then(response => {
+        this.tableData = response.data
+        this.total = this.tableData.length
+        this.loading = false
+      })
+    },
+    codeChangeName(row) {
+      var codeList = this.stationList
+      for (let i = 0; i < codeList.length; i++) {
+        if (row.cellValue == codeList[i].value) {
+          return codeList[i].label
+        }
+      }
+    },
+  }
+}
+</script>
+
+<style scoped>
+</style>

+ 18 - 73
cpp-ui/src/views/statistics/reportData/index.vue

@@ -94,15 +94,25 @@ export default {
       tableData: [],
       loading: false,
       electricFieldTypeEnum: '',
+      allFileTypeList: [],
+      solarList:[],
+      windList:[]
     }
   },
   created() {
-    this.getStationCode()
+    this.getFileTypeInfo()
   },
   mounted() {
   },
   computed: {},
   methods: {
+    getFileTypeInfo(){
+      this.$axios.get('/enumSelect/allUseFileType').then(response => {
+        this.solarList = response.data.solar
+        this.windList = response.data.wind
+        this.getStationCode()
+      })
+    },
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
       if (this.pageSize != pageSize) {
@@ -129,78 +139,8 @@ export default {
         this.stationList = response.data
         if (this.stationList.length > 0) {
           this.stationCode = this.stationList[0].value
-          this.getElectricFieldTypeEnum()
-        }
-      })
-    },
-    getElectricFieldTypeEnum() {
-      this.loading = true
-      const param = {
-        "stationCode": this.stationCode,
-      }
-      this.$axios.get('reportData/getElectricFieldTypeEnum', {params: param}).then(response => {
-        this.electricFieldTypeEnum = response.data
-        if (this.electricFieldTypeEnum === 'E1') {
-          this.fileType = [{
-            value: 'dq',
-            label: '短期'
-          }, {
-            value: 'rdq',
-            label: '调控后短期'
-          }, {
-            value: 'cdq',
-            label: '超短期'
-          }, {
-            value: 'rcdq',
-            label: '调控后超短期'
-          }, {
-            value: 'nwp',
-            label: 'Nwp'
-          }, {
-            value: 'qxz',
-            label: '气象站'
-          }, {
-            value: 'nbq',
-            label: '逆变器'
-          }, {
-            value: 'rp',
-            label: '实发功率'
-          }, {
-            value: 'status',
-            label: '运行信息'
-          }]
-        } else {
-          this.fileType = [{
-            value: 'dq',
-            label: '短期'
-          }, {
-            value: 'rdq',
-            label: '调控后短期'
-          }, {
-            value: 'cdq',
-            label: '超短期'
-          }, {
-            value: 'rcdq',
-            label: '调控后超短期'
-          }, {
-            value: 'nwp',
-            label: 'Nwp'
-          }, {
-            value: 'cft',
-            label: '测风塔'
-          }, {
-            value: 'fj',
-            label: '风机'
-          }, {
-            value: 'rp',
-            label: '实发功率'
-          }, {
-            value: 'status',
-            label: '运行信息'
-          }]
+          this.queryByStationCode()
         }
-        // this.fileTypeName = this.fileType[0].value
-        this.queryByStationCode()
       })
     },
     queryByStationCode() {
@@ -218,8 +158,13 @@ export default {
         "endTime": endTime,
       }
       this.$axios.get('/reportData/getData', {params: param}).then(response => {
-        this.tableData = response.data
+        this.tableData = response.data.data
         this.total = this.tableData.length
+        if (response.data.type === 'E1'){
+          this.fileType = this.solarList
+        }else {
+          this.fileType = this.windList
+        }
         this.loading = false
       })
     },