Browse Source

Merge remote-tracking branch 'origin/master'

wanghc 3 years ago
parent
commit
df976c6a2d
22 changed files with 323 additions and 69 deletions
  1. 6 0
      ipfcst-client/pom.xml
  2. 4 3
      ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java
  3. 12 2
      ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java
  4. 13 5
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java
  5. 2 2
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java
  6. 2 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/PowerStationStatusDataRepository.java
  7. 3 2
      ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortHisTerm/index.vue
  8. 5 6
      ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortTerm/charts/index.vue
  9. 3 3
      ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortTerm/index.vue
  10. 6 3
      ipfcst-console/src/main/frontend/views/dataquery/forecastPowerUltraShortTerm16/index.vue
  11. 2 6
      ipfcst-console/src/main/frontend/views/dataquery/nwp/charts/index.vue
  12. 5 1
      ipfcst-console/src/main/frontend/views/dataquery/nwp/index.vue
  13. 2 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/QuartzController.java
  14. 1 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerShortTermService.java
  15. 11 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java
  16. 8 5
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InitJobClassService.java
  17. 2 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java
  18. 213 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java
  19. 3 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/Base102Service.java
  20. 0 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/config/AppenderFactory.java
  21. 7 6
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadObjectController.java
  22. 13 7
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/ByteUtil.java

+ 6 - 0
ipfcst-client/pom.xml

@@ -73,6 +73,12 @@
             <artifactId>ganymed-ssh2</artifactId>
             <version>build210</version>
         </dependency>
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <version>RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <dependencyManagement>
         <dependencies>

+ 4 - 3
ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java

@@ -73,11 +73,12 @@ public class DownloadFileJob {
                         }
                         log.info("开始下载文件:{}。", fileCreateLog.getFileName());
                         String url = properties.getProperty("v3cloud.fileDownUrl") + fileCreateLog.getId();// "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
-                        long size = HttpUtil.downloadFile(url, path + File.separatorChar + fileCreateLog.getFileName());
+                        String targetPath = path + File.separatorChar +stationCode+File.separatorChar +"new"+File.separatorChar+ fileCreateLog.getFileName();
+                        long size = HttpUtil.downloadFile(url,targetPath);
                         if (size > 0) {
                             isDownFileId.add(fileCreateLog.getId());
-                            log.info("成功下载文件:{}", path + File.separatorChar + fileCreateLog.getFileName());
-                            filedownLoadList.add(path + File.separatorChar + fileCreateLog.getFileName());
+                            log.info("成功下载文件:{}", targetPath);
+                            filedownLoadList.add(targetPath);
                         }
                     }
                 } catch (Exception e) {

+ 12 - 2
ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java

@@ -1,6 +1,9 @@
 package com.jiayue.client.service;
 
+import cn.hutool.core.codec.Base64;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.client.util.MD5Util;
@@ -11,6 +14,7 @@ import org.springframework.stereotype.Repository;
 
 import java.util.*;
 
+
 @Repository
 @Slf4j
 public class SendDataService {
@@ -311,8 +315,13 @@ public class SendDataService {
         resultMap.put("sign", sign);
 
         String reqStr = JSONUtil.toJsonStr(resultMap);
-        log.info("回传数据给数据中心,请求报文:{}", reqStr);
-        String resp = HttpUtil.post(properties.getProperty("remote.dcUrl"), reqStr);
+        log.info("回传数据给数据中心,请求原报文:{}", reqStr);
+        log.info("回传数据给数据中心,请求地址:{}", properties.getProperty("remote.dcUrl")+"");
+        Map<String, Object> reqMap = new HashMap<>();
+        reqMap.put("reqMsg", Base64.encode(ZipUtil.gzip(reqStr, CharsetUtil.CHARSET_UTF_8.name())));
+        log.info("回传数据给数据中心,压缩加密后报文:{}", reqMap);
+        String resp = HttpUtil.get(properties.getProperty("remote.dcUrl"),reqMap);
+       // String resp = HttpUtil.post(properties.getProperty("remote.dcUrl")+"", reqStr);
         if (resp.length() > 0) {
             if (!"0".equals(JSONUtil.parseObj(resp).get("code"))) {
                 new Exception("回传数据给数据中心错误:" + resp);
@@ -320,4 +329,5 @@ public class SendDataService {
         }
         log.info("回传数据给数据中心,获得响应报文:{}", resp);
     }
+
 }

+ 13 - 5
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java

@@ -132,12 +132,20 @@ public abstract class CommonUtil {
             zos.putNextEntry(new ZipEntry(name));
             // copy文件到zip输出流中
             int len;
-            FileInputStream in = new FileInputStream(sourceFile);
-            while ((len = in.read(buf)) != -1) {
-                zos.write(buf, 0, len);
+            FileInputStream in = null;
+            try {
+                in = new FileInputStream(sourceFile);
+                while ((len = in.read(buf)) != -1) {
+                    zos.write(buf, 0, len);
+                }
+                zos.closeEntry();
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (in != null) {
+                    in.close();
+                }
             }
-            zos.closeEntry();
-            in.close();
         } else {
             File[] listFiles = sourceFile.listFiles();
             if (listFiles == null || listFiles.length == 0) {

+ 2 - 2
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java

@@ -210,8 +210,8 @@ public class DateTimeUtil {
     public static boolean checkInSunriseAndSunset(Long time, double dfLonIn, double dfLatIn) {
         Date date = new Date(time);
 
-        String str1 = SunRiseSet.getSunrise(new BigDecimal(dfLonIn), new BigDecimal(dfLatIn), date);
-        String str2 = SunRiseSet.getSunset(new BigDecimal(dfLonIn), new BigDecimal(dfLatIn), date);
+        String str1 = SunRiseSet.getSunrise(BigDecimal.valueOf(dfLonIn), BigDecimal.valueOf(dfLatIn), date);
+        String str2 = SunRiseSet.getSunset(BigDecimal.valueOf(dfLonIn), BigDecimal.valueOf(dfLatIn), date);
 
         Date dt1 = null;
         Date dt2 = null;

+ 2 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/PowerStationStatusDataRepository.java

@@ -30,4 +30,6 @@ public interface PowerStationStatusDataRepository extends BaseRepository<PowerSt
 	 * @return 结果集
 	 */
 	PowerStationStatusData findByTime(Date queryTime);
+
+	List<PowerStationStatusData> findByTimeBetween(Date startTime, Date endTime);
 }

+ 3 - 2
ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortHisTerm/index.vue

@@ -169,7 +169,7 @@ export default {
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
       if (this.pageSize != pageSize) {
-        this.changePageSize(pageSize)
+        this.currentPage =1
       }
       this.pageSize = pageSize
       this.startTime = this.queryStartTime
@@ -178,7 +178,8 @@ export default {
       this.getTable();
     },
     changePageSize(pageSize) {
-      this.displayConfigPageSize.showCode = pageSize
+      this.currentPage =1
+      //this.displayConfigPageSize.showCode = pageSize
       this.$axios.post('displayConfig/', this.displayConfigPageSize).then((res) => {
         this.displayConfigPageSize = res.data
         // this.$message.success('PageSize设置成功' )

+ 5 - 6
ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortTerm/charts/index.vue

@@ -55,7 +55,7 @@
             textStyle: {
               fontWeight: 'normal',
               fontSize: 16,
-              color: '#F1F1F3'
+              color: '#040606'
             },
             left: '1%'
           },
@@ -63,7 +63,7 @@
             trigger: 'axis',
             axisPointer: {
               lineStyle: {
-                color: '#57617B'
+                color: '#040606'
               }
             }
           },
@@ -76,8 +76,7 @@
             data: ['实时短期预测'],
             right: '4%',
             textStyle: {
-              fontSize: 12,
-              color: '#F1F1F3'
+              fontSize: 12
             }
           },
           dataZoom: [{
@@ -105,7 +104,7 @@
             boundaryGap: false,
             axisLine: {
               lineStyle: {
-                color: '#ffffff'
+                color: '#040606'
               }
             },
             data: timeaxis
@@ -118,7 +117,7 @@
             },
             axisLine: {
               lineStyle: {
-                color: '#ffffff'
+                color: '#040606'
               }
             },
             axisLabel: {

+ 3 - 3
ipfcst-console/src/main/frontend/views/dataquery/forecastPowerShortTerm/index.vue

@@ -203,10 +203,10 @@ export default {
       this.pageSize = pageSize
       this.startTime = this.queryStartTime
       this.endTime = this.queryEndTime
-      this.loading = true
-      this.getTable();
+      this.getTable()
     },
     changePageSize(pageSize) {
+      this.currentPage = 1
       this.displayConfigPageSize.showCode = pageSize
       this.$axios.post('displayConfig/', this.displayConfigPageSize).then((res) => {
         this.displayConfigPageSize = res.data
@@ -284,7 +284,7 @@ export default {
         this.showToolBar = true
       }
 
-    },
+    }
   }
 }
 </script>

+ 6 - 3
ipfcst-console/src/main/frontend/views/dataquery/forecastPowerUltraShortTerm16/index.vue

@@ -50,7 +50,7 @@
               :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)">
               <vxe-table-column field="times" title="预测时间" :formatter="dateFormat" width="180" sortable
                                 min-width="150"></vxe-table-column>
-              <!--              <vxe-table-column field="realValue" title="实际功率" min-width="60"></vxe-table-column>-->
+                         <vxe-table-column field="realValue" title="实际功率" min-width="60"></vxe-table-column>
               <vxe-table-column field="value1" title="第1个时刻" min-width="60"></vxe-table-column>
               <vxe-table-column field="value2" title="第2个时刻" min-width="60"></vxe-table-column>
               <vxe-table-column field="value3" title="第3个时刻" min-width="60"></vxe-table-column>
@@ -147,10 +147,10 @@ export default {
       this.$axios.get('/findByForecastRealTimeUltraShortTerm16/' + startTime + '/' + stationCode).then((res) => {
         const value = res.data.value
         this.tableData = []
-        for (let i = 1; i < res.data.value.length; i++) {
+        for (let i = 1; i < res.data.realDatas.length; i++) {
           const temp = {}
           temp.times = res.data.times[i]
-          //temp.realValue = res.data.realDatas[i]
+          temp.realValue = res.data.realDatas[i]
           temp.value1 = value.value1[i]
           temp.value2 = value.value2[i]
           temp.value3 = value.value3[i]
@@ -187,6 +187,9 @@ export default {
     },
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
+      if (this.pageSize != pageSize) {
+        this.currentPage =1
+      }
       this.pageSize = pageSize
       this.startTime = this.queryStartTime
     },

+ 2 - 6
ipfcst-console/src/main/frontend/views/dataquery/nwp/charts/index.vue

@@ -280,8 +280,7 @@ export default {
           text: 'nwp信息',
           textStyle: {
             fontWeight: 'normal',
-            fontSize: 16,
-            color: '#79acff'
+            fontSize: 16
           },
           left: '1%'
         },
@@ -311,8 +310,7 @@ export default {
           data: [],
           right: '4%',
           textStyle: {
-            fontSize: 12,
-            color: '#79acff'
+            fontSize: 12
           },
           selected: {}
         },
@@ -341,7 +339,6 @@ export default {
           boundaryGap: false,
           axisLine: {
             lineStyle: {
-              color: '#79acff'
             }
           },
           data: []
@@ -354,7 +351,6 @@ export default {
           },
           axisLine: {
             lineStyle: {
-              color: '#79acff'
             }
           },
 

+ 5 - 1
ipfcst-console/src/main/frontend/views/dataquery/nwp/index.vue

@@ -74,7 +74,7 @@
                 background
                 :loading="loading"
                 :current-page.sync="currentPage"
-                :page-size.sync="pageSize"
+                :page-size="pageSize"
                 :total="total"
                 @page-change="handlePageChange"
                 :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
@@ -208,6 +208,10 @@ export default {
     },
     handlePageChange({currentPage, pageSize}) {
       this.currentPage = currentPage
+
+      if (this.pageSize != pageSize) {
+        this.currentPage =1
+      }
       this.pageSize = pageSize
       this.startTime = this.queryStartTime
       this.endTime = this.queryEndTime

+ 2 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/QuartzController.java

@@ -67,11 +67,11 @@ public class QuartzController {
   @SneakyThrows
   @PutMapping(value = "quartzs")
   public ResponseVO stateQuartz(@RequestBody final Quartz qt) {
-    final boolean flag = quartzService.save(qt);
+    boolean flag = quartzService.save(qt);
     if (flag) {
       return ResponseVO.success("修改成功!");
     } else {
-      return ResponseVO.success("修改成功!");
+      return ResponseVO.fail("修改失败!");
     }
   }
 

+ 1 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerShortTermService.java

@@ -130,7 +130,7 @@ public class ForecastPowerShortTermService extends BaseService {
         _forecastPowerShortTerm.getFpValue().multiply(openCapacityMap != null ? openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()) : electricFieldInfo.getCapacity())
           .divide(electricFieldInfo.getCapacity(), 2, RoundingMode.HALF_UP);
 
-      forecastPowerShortTermHis.setAbleValue(ableValue.compareTo(lpl) == -1 ? lpl : ableValue);
+      forecastPowerShortTermHis.setAbleValue(ableValue.compareTo(lpl) < 0 ? lpl : ableValue);
       forecastPowerShortTermHis.setPredictionModelEnum(_forecastPowerShortTerm.getPredictionModelEnum());
       forecastPowerShortTermHis.setGenDate(new Date());
       forecastPowerShortTermHis.setSuCapacity(openCapacityMap != null ? openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()) : electricFieldInfo.getCapacity());

+ 11 - 9
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java

@@ -51,6 +51,8 @@ public class ForecastPowerUltraShortTermService extends BaseService {
   ForecastPowerUltraShortTermHisRepository forecastPowerUltraShortTermHisRepository;
   @Autowired
   ForecastPowerShortTermService forecastPowerShortTermService;
+  @Autowired
+  PowerStationStatusDataService powerStationStatusDataService;
 
   /**
    * 获取超短期预测功率,当数据库中超短期预测记录不足查询所需时,进行本地化计算,用于上报专用
@@ -175,7 +177,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         PowerStationStatusData realPower = realPowerList.get(0);
         // 将实际功率替换到对应的超短期点位上
         ForecastPowerUltraShortTermHis d = forecastPowerUltraShortTermHiss.get(replacePoint - 1);
-        if (realPower.getRealValue().compareTo(new BigDecimal(0)) != -1) {
+        if (realPower.getRealValue().compareTo(new BigDecimal(0)) >=0) {
           d.setAbleValue(realPower.getRealValue());
         }
       }
@@ -185,7 +187,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     BigDecimal lpl = new BigDecimal(lowerPredictionLimit);
 
     forecastPowerUltraShortTermHiss.forEach(s -> {
-      if (s.getAbleValue().compareTo(lpl) == -1) {
+      if (s.getAbleValue().compareTo(lpl) < 0) {
         s.setAbleValue(lpl);
       }
     });
@@ -297,7 +299,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     Date startTime = DateUtils.addMinutes(currentTime, -10);
     Date endTime = DateUtils.addMinutes(currentTime, 1);
     List<PowerStationStatusData> powerStationStatusDataList = this.powerStationStatusDataRepository.findByTimeBetweenAndStationCode(startTime, endTime, stationCode);
-    List<PowerStationStatusData> filterList = powerStationStatusDataList.stream().filter(t -> t.getAbleValue().compareTo(new BigDecimal("-1")) == 1).collect(Collectors.toList());
+    List<PowerStationStatusData> filterList = powerStationStatusDataList.stream().filter(t -> t.getAbleValue().compareTo(new BigDecimal("-1")) > 0).collect(Collectors.toList());
     String coe = super.getSysParameter("CDQ_COE", "1.05", stationCode);
 
     long monentTime = 0L;
@@ -365,7 +367,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
         forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E9);
         forecastPowerUltraShortTerm.setCoefficientValue(ustPower);
-        forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, RoundingMode.HALF_UP));
+        forecastPowerUltraShortTerm.setDifferenceValue(BigDecimal.valueOf(-0.99).setScale(2, RoundingMode.HALF_UP));
         forecastPowerUltraShortTerm.setFpValue(ustPower);
         forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
         forecastPowerUltraShortTerm.setStationCode(stationCode);
@@ -433,7 +435,6 @@ public class ForecastPowerUltraShortTermService extends BaseService {
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public Map<String, Object> findByForecastRealTimeUltraShortTerm16(Long startTime, String stationCode) {
     long endTime = startTime + 60 * 60 * 1000 * 24;
-//    List<Map<String,Object>> valueList16 = new ArrayList<>();
     //取出16点数据存入集合中
     Map<String, Object> realPowerMap = new HashMap<>();
     List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = forecastPowerUltraShortTermHisRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
@@ -447,7 +448,6 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         startTime = startTime - (startTime % timeStep);
       }
       List<Float> ableDatas = new ArrayList<>();
-
       for (long i = startTime; i < endTime; i = i + 900000L) {
         long finalI = i;
         List<ForecastPowerUltraShortTermHis> p1 = filterList.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
@@ -458,15 +458,17 @@ public class ForecastPowerUltraShortTermService extends BaseService {
           } else {
             ableDatas.add(p1.get(0).getAbleValue().floatValue());
           }
+
         } else {
-          ableDatas.add(null);
+          ableDatas.add(0f);
         }
+
       }
       realPowerMap.put("value" + p, ableDatas);
     }
 
-    //Map<String, Object> map = powerStationStatusDataService.findByTimeBetweenForContrast(new Date(startTime), new Date(endTime), 900000l);
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map = powerStationStatusDataService.findByTimeBetweenForContrast(new Date(startTime), new Date(endTime), 900000l);
+
     ElectricField electricField = electricFieldService.getSingleStation(stationCode);
     map.put("value", realPowerMap);
     map.put("capacity", electricField.getCapacity());

+ 8 - 5
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InitJobClassService.java

@@ -1,6 +1,7 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.data.entity.InitJobClass;
+import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.repository.InitJobClassRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
@@ -14,10 +15,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 定时逻辑
@@ -145,7 +143,12 @@ public class InitJobClassService extends BaseService {
    * @return InitJobClass
    */
   public InitJobClass findById(String id) {
-    return initJobClassRepository.findById(Integer.parseInt(id)).get();
+    Optional<InitJobClass> optional = initJobClassRepository.findById(Integer.parseInt(id));
+    InitJobClass initJobClass = null;
+    if (optional.isPresent()) {
+      initJobClass = optional.get();
+    }
+    return initJobClass;
   }
 
   public InitJobClass findByName(String jobClassName) {

+ 2 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java

@@ -75,7 +75,7 @@ public class OverHaulPlanService {
    * 查询检修计划信息(分页)
    */
   public Page<OverhaulPlan> get(final OverhaulPlan overhaulPlan, final Integer page, final Integer size) {
-    getAll();
+//    getAll();
     ExampleMatcher matcher =
       ExampleMatcher.matching().withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains());
     Example<OverhaulPlan> example = Example.of(overhaulPlan, matcher);
@@ -88,7 +88,7 @@ public class OverHaulPlanService {
    * 查询检修计划信息(分页)
    */
   public Page<OverhaulPlan> getByStationCode(final OverhaulPlan overhaulPlan, final Integer page, final Integer size, final String stationCode) {
-    getAll();
+//    getAll();
     overhaulPlan.setStationCode(stationCode);
     ExampleMatcher matcher =
       ExampleMatcher.matching().withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains())

+ 213 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java

@@ -0,0 +1,213 @@
+package com.jiayue.ipfcst.console.service;
+import com.jiayue.ipfcst.common.data.entity.PowerStationStatusData;
+import com.jiayue.ipfcst.common.data.repository.PowerStationStatusDataRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 实际功率
+ */
+@Service
+public class PowerStationStatusDataService extends BaseService {
+
+  private final PowerStationStatusDataRepository powerStationStatusDataRepository;
+
+  @Autowired
+  public PowerStationStatusDataService(PowerStationStatusDataRepository powerStationStatusDataRepository) {
+    this.powerStationStatusDataRepository = powerStationStatusDataRepository;
+  }
+
+
+  /**
+   * 根据开始时间和结束时间查询 场站功率状态
+   * 超短期数据展示搭配实际功率使用
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @return 结果集
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Map<String, Object> findByTimeBetweenForContrast(Date startTime, Date endTime, Long timeStep) {
+    Map<String, Object> map = new HashMap<>();
+    List<PowerStationStatusData> list = new ArrayList<>();
+
+    list = powerStationStatusDataRepository.findByTimeBetween(startTime, endTime);
+
+
+    long startTimeLong = startTime.getTime();
+    long endTimeLong = endTime.getTime();
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    if (startTimeLong % timeStep != 0) {
+      startTimeLong = startTimeLong - (startTimeLong % timeStep);
+    }
+    List<Float> realDatas = new ArrayList<>();
+    List<Float> ableDatas = new ArrayList<>();
+    List<Float> theoryDatas = new ArrayList<>();
+    List<Float> referencePowerByMeasuringDatas = new ArrayList<>();
+    List<Float> referencePowerBySampleDatas = new ArrayList<>();
+    List<String> times = new ArrayList<>();
+
+    for (long i = startTimeLong; i < endTimeLong; i = i + timeStep) {
+      long finalI = i;
+      List<PowerStationStatusData> p = list.stream().filter(t -> t.getTime().getTime() == finalI).collect(Collectors.toList());
+      if (p != null && p.size() > 0) {
+
+        if (p.get(0).getRealValue().compareTo(new BigDecimal(-99)) == 0) {
+          realDatas.add(null);
+        } else {
+          realDatas.add(p.get(0).getRealValue().floatValue());
+        }
+
+        if (p.get(0).getAbleValue().compareTo(new BigDecimal(-99)) == 0) {
+          ableDatas.add(null);
+        } else {
+          ableDatas.add(p.get(0).getAbleValue().floatValue());
+        }
+
+        if (p.get(0).getTheoryValue().compareTo(new BigDecimal(-99)) == 0) {
+          theoryDatas.add(null);
+        } else {
+          theoryDatas.add(p.get(0).getTheoryValue().floatValue());
+        }
+
+        if (p.get(0).getReferencePowerByMeasuring().compareTo(new BigDecimal(-99)) == 0) {
+          referencePowerByMeasuringDatas.add(null);
+        } else {
+          referencePowerByMeasuringDatas.add(p.get(0).getReferencePowerByMeasuring().floatValue());
+        }
+
+        if (p.get(0).getReferencePowerBySample().compareTo(new BigDecimal(-99)) == 0) {
+          referencePowerBySampleDatas.add(null);
+        } else {
+          referencePowerBySampleDatas.add(p.get(0).getReferencePowerBySample().floatValue());
+        }
+        String timeFormat = sdf.format(new Date(i));
+        times.add(timeFormat);
+
+      } else {
+        String timeFormat = sdf.format(new Date(i));
+        times.add(timeFormat);
+        realDatas.add(null);
+        ableDatas.add(null);
+        theoryDatas.add(null);
+        referencePowerByMeasuringDatas.add(null);
+        referencePowerBySampleDatas.add(null);
+
+      }
+    }
+
+
+    map.put("times", times);
+    map.put("realDatas", realDatas);
+    map.put("ableDatas", ableDatas);
+    map.put("theoryDatas", theoryDatas);
+    map.put("referencePowerByMeasuringDatas", referencePowerByMeasuringDatas);
+    map.put("referencePowerBySampleDatas", referencePowerBySampleDatas);
+
+    return map;
+  }
+
+
+  /**
+   * 对集合进行 -99替换null操作,主要用于图标展示空值
+   *
+   * @param datas 需要替换集合
+   */
+  public void defaultReplace(List<PowerStationStatusData> datas) {
+    BigDecimal nullBig = new BigDecimal(-99);
+    for (PowerStationStatusData p : datas) {
+      if (p.getRealValue().compareTo(nullBig) == 0) {
+        p.setRealValue(null);
+      }
+      if (p.getAbleValue().compareTo(nullBig) == 0) {
+        p.setAbleValue(null);
+      }
+      if (p.getTheoryValue().compareTo(nullBig) == 0) {
+        p.setTheoryValue(null);
+      }
+      if (p.getOpenCapacity().compareTo(nullBig) == 0) {
+        p.setOpenCapacity(null);
+      }
+      if (p.getCapacity().compareTo(nullBig) == 0) {
+        p.setCapacity(null);
+      }
+      if (p.getOnSiteObstructed().compareTo(nullBig) == 0) {
+        p.setOnSiteObstructed(null);
+      }
+      if (p.getOffSiteObstructed().compareTo(nullBig) == 0) {
+        p.setOffSiteObstructed(null);
+      }
+    }
+
+  }
+
+  /**
+   * 受阻电量查询(已废弃)
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<Map<String, Object>> findBalkPower(Date startTime, Date endTime) {
+
+    List<Map<String, Object>> resultList = new ArrayList<>();
+
+
+    List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetween(startTime, endTime);
+
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    for (PowerStationStatusData powerStationStatusData : powerStationStatusDataList) {
+      Map<String, Object> map = new HashMap<>();
+      map.put("time", sdf.format(powerStationStatusData.getTime()));
+      map.put("onSiteObstructed", powerStationStatusData.getOnSiteObstructed());
+      map.put("offSiteObstructed", powerStationStatusData.getOffSiteObstructed());
+      BigDecimal b = powerStationStatusData.getAbleValue().subtract(powerStationStatusData.getRealValue());
+      if (powerStationStatusData.getRealValue().floatValue() != 0) {
+        map.put("abandonmentRate", b.divide(powerStationStatusData.getRealValue(), 2, BigDecimal.ROUND_HALF_UP));
+      } else {
+        map.put("abandonmentRate", 0);
+      }
+
+      resultList.add(map);
+
+    }
+
+//    Sort sort = Sort.by(Sort.Direction.DESC, "time");
+//    if (sortOrder.contains("asc")) {
+//      sort = Sort.by(Sort.Direction.ASC, "time");
+//    }
+//    Specification<PowerStationStatusData> specification = this.Specification(startTime, endTime);
+//    Pageable pageable = PageRequest.of(page - 1, size, sort);
+//    Page pages = powerStationStatusDataRepository.findAll(specification, pageable);
+//    List<PowerStationStatusData> datas = new ArrayList<>();
+//    datas = pages.getContent();
+//    map.put("content", datas);
+//    map.put("count", pages.getTotalElements());
+
+    return resultList;
+
+
+  }
+
+  /**
+   * 根据时间查询数据并根据时间正序排序
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<PowerStationStatusData> findByTimeBetween(Long startTime, Long endTime) {
+    List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
+    Collections.sort(powerStationStatusDataList, Comparator.comparing(PowerStationStatusData::getTime));
+    return powerStationStatusDataList;
+  }
+}
+

+ 3 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/IEC102/Base102Service.java

@@ -56,7 +56,9 @@ public class Base102Service {
     String fileNameKey = "";
     for (Map.Entry<String, FileMutableInteger> entry : filterMap.entrySet()) {
       fileNameKey = entry.getKey();
-      break;
+      if (!"".equals(fileNameKey)){
+        break;
+      }
     }
     String[] keys = new String[3];
     String tempFileName = fileNameKey;

+ 0 - 3
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/config/AppenderFactory.java

@@ -36,9 +36,6 @@ public class AppenderFactory {
     if (logger != null) {
       return logger;
     } else {
-      if (logger != null) {
-        return logger;
-      }
       logger = getAppender(name, type, no);
       FileConstant.uploadLogMap.put(no, logger);
     }

+ 7 - 6
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/controller/UploadObjectController.java

@@ -1,8 +1,10 @@
 package com.jiayue.ipfcst.fileupload.controller;
 
 import com.jiayue.ipfcst.aop.SaveValidate;
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
 import com.jiayue.ipfcst.common.data.entity.UploadObject;
 import com.jiayue.ipfcst.common.data.repository.UploadObjectRepository;
@@ -12,10 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @RestController
@@ -133,8 +132,10 @@ public class UploadObjectController {
   @GetMapping("getByuploadObjectId/{uploadObjectId}")
   public ResponseVO getFileTypeByupId(@PathVariable("uploadObjectId") Integer uploadObjectId) {
     List<UploadObject> list = new ArrayList<>();
-    UploadObject uploadObject = uploadObjectRepository.findById(uploadObjectId).get();
-    list.add(uploadObject);
+    Optional<UploadObject> optional = uploadObjectRepository.findById(uploadObjectId);
+    if (optional.isPresent()) {
+      list.add(optional.get());
+    }
     return ResponseVO.success(list);
   }
 

+ 13 - 7
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/util/ByteUtil.java

@@ -187,7 +187,7 @@ public abstract class ByteUtil {
     for (int i = 0; i < byteArray.length; i++) {//因为是16进制,最多只会占用4位,转换成字节需要两个16进制的字符,高位在先
       byte high = (byte) (Character.digit(hexString.charAt(k), 16) & 0xff);
       byte low = (byte) (Character.digit(hexString.charAt(k + 1), 16) & 0xff);
-      byteArray[i] = (byte) (high << 4 | low);
+      byteArray[i] = (byte) (high << 4 | low & 0xff);
       k += 2;
     }
     return byteArray;
@@ -200,14 +200,20 @@ public abstract class ByteUtil {
    * @return string
    */
   public static String Byte2String(byte[] ba) {
-    if (ba == null || ba.length == 0) {
-      return null;
-    }
+    if(ba == null || ba.length == 0)
+    { return null;}
     Formatter f = new Formatter();
-    for (byte b : ba) {
-      f.format("%02x ", b);
+    String resultStr;
+    try {
+      for (int i = 0; i < ba.length; ++i) {
+        f.format("%02x ", ba[i]);
+      }
+      resultStr = f.toString();
+    }
+    finally {
+      f.close();
     }
-    return f.toString();
+    return resultStr;
   }
 
   /**