Ver Fonte

Merge remote-tracking branch 'origin/master'

wangtao há 3 anos atrás
pai
commit
d1031b7adc
24 ficheiros alterados com 1488 adições e 305 exclusões
  1. 5 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java
  2. 3 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/SysAlarm.java
  3. 7 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/ForecastPowerShortTermHisRepository.java
  4. 5 2
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/InverterStatusDataRepository.java
  5. 5 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WeatherStationStatusDataRepository.java
  6. 5 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WindTowerStatusDataRepository.java
  7. 5 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WindTurbineStatusDataRepository.java
  8. 6 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/BaseService.java
  9. 2 2
      ipfcst-console/pom.xml
  10. 171 168
      ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/charts/index.vue
  11. 21 23
      ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/index.vue
  12. 1 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PowerStationStatusDataController.java
  13. 32 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/DeleteHistoryDataJob.java
  14. 18 7
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/ReceiveDataJob.java
  15. 48 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DeleteHistoryDataService.java
  16. 1 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationDataPacker.java
  17. 55 60
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java
  18. 411 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveAllDataService.java
  19. 527 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveAllTypeService.java
  20. 39 31
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveDataService.java
  21. 44 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysAlarmService.java
  22. 51 4
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java
  23. 24 5
      ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java
  24. 2 2
      ipfcst-console/src/main/resources/application.yml

+ 5 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java

@@ -27,6 +27,11 @@ public class ElectricField extends AbstractBaseEntity {
     @Id
     @Column
     private String stationCode;
+    /**
+     * 场站id
+     */
+    @Column
+    private String electricFieldId;
 
     /**
      * 电站名称

+ 3 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/SysAlarm.java

@@ -74,4 +74,7 @@ public class SysAlarm extends AbstractBaseEntity {
     @Column
     private String pritority;
 
+    @Column
+    private String stationCode;
+
 }

+ 7 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/ForecastPowerShortTermHisRepository.java

@@ -4,6 +4,7 @@ import com.jiayue.ipfcst.common.data.entity.ForecastPowerShortTermHis;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -15,6 +16,12 @@ import java.util.List;
  */
 public interface ForecastPowerShortTermHisRepository extends BaseRepository<ForecastPowerShortTermHis, Integer> {
     /**
+     * 根据传入的时间删除之前历史数据
+     * @param time 时间
+     */
+    void deleteByGenDateBefore(Date time);
+
+    /**
      * 根据时间段删除当日凌晨零点以后生成的短期历史期数据
      *
      * @param startTime 开始时间

+ 5 - 2
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/InverterStatusDataRepository.java

@@ -13,8 +13,11 @@ import java.util.List;
  * @since 2019/8/6 13:00
  */
 public interface InverterStatusDataRepository extends BaseRepository<InverterStatusData, Integer> {
-
-
+    /**
+     * 根据传入的时间删除之前历史数据
+     * @param time 时间
+     */
+    void deleteByTimeBefore(Date time);
     List<InverterStatusData> findByTimeBetween(Date startTime, Date endTime);
     List<InverterStatusData> findByTimeBetweenAndEquipmentIdIn(Date startTime, Date endTime, Integer[] no);
     List<InverterStatusData> findByTimeBetweenAndEquipmentId(Date startTime, Date endTime, String no);

+ 5 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WeatherStationStatusDataRepository.java

@@ -23,4 +23,9 @@ public interface WeatherStationStatusDataRepository extends BaseRepository<Weath
 	 */
 	List<WeatherStationStatusData> findByStationCodeAndTimeBetweenAndEquipmentId(String stationCode,Date startTime, Date endTime, String no);
 
+	/**
+	 * 根据传入的时间删除之前历史数据
+	 * @param time 时间
+	 */
+	void deleteByTimeBefore(Date time);
 }

+ 5 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WindTowerStatusDataRepository.java

@@ -16,6 +16,11 @@ import java.util.List;
  */
 public interface WindTowerStatusDataRepository extends JpaRepository<WindTowerStatusData, Integer>, JpaSpecificationExecutor<WindTowerStatusData> {
 	/**
+	 * 根据传入的时间删除之前历史数据
+	 * @param time 时间
+	 */
+	void deleteByTimeBefore(Date time);
+	/**
 	 * 根据设备号和时间段获取测风塔数据
 	 *
 	 * @param equipmentNo

+ 5 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WindTurbineStatusDataRepository.java

@@ -17,4 +17,9 @@ public interface WindTurbineStatusDataRepository extends BaseRepository<WindTurb
     List<WindTurbineStatusData> findByTimeBetweenAndEquipmentId(Date startTime, Date endTime, String no);
 
     List<WindTurbineStatusData> findByTimeBetweenAndEquipmentIdIn(Date startTime, Date endTime, Integer[] no);
+    /**
+     * 根据传入的时间删除之前历史数据
+     * @param time 时间
+     */
+    void deleteByTimeBefore(Date time);
 }

+ 6 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/BaseService.java

@@ -3,12 +3,16 @@ package com.jiayue.ipfcst.common.data.service;
 import cn.hutool.core.date.DateUtil;
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.NumberUtils;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmStatusEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
+import com.jiayue.ipfcst.common.data.entity.SysAlarm;
 import com.jiayue.ipfcst.common.data.entity.SysParameter;
 import com.jiayue.ipfcst.common.data.job.BaseJob;
 import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
 import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
+import com.jiayue.ipfcst.common.data.repository.SysAlarmRepository;
 import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
 import com.sun.istack.internal.NotNull;
 import lombok.NonNull;
@@ -45,6 +49,8 @@ public class BaseService {
 
 	private Scheduler scheduler;
 
+	private SysAlarmRepository sysAlarmRepository;
+
 	@Autowired
 	public void setOverhaulPlanRepository(OverhaulPlanRepository overhaulPlanRepository) {
 		this.overhaulPlanRepository = overhaulPlanRepository;

+ 2 - 2
ipfcst-console/pom.xml

@@ -251,7 +251,7 @@
     <profile>
       <id>window</id>
       <properties>
-        <npm>npm.cmd</npm>
+        <npm>npm</npm>
       </properties>
       <activation>
         <activeByDefault>true</activeByDefault>
@@ -300,7 +300,7 @@
             <!--<verbose />-->
             <!-- 解决maven命令编译报错,因为rt.jar 和jce.jar在jre的lib下面,不在jdk的lib下面,
             导致maven找不到(java7以后会出现这个问题),将这2个jar包拷贝到jdk的lib下面估计也好使-->
-            <bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>
+            <bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar</bootclasspath>
           </compilerArguments>
         </configuration>
       </plugin>

+ 171 - 168
ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/charts/index.vue

@@ -61,7 +61,7 @@
             textStyle: {
               fontWeight: 'normal',
               fontSize: 16,
-              color: '#F1F1F3'
+              color: '#000000'
             },
             left: '1%'
           },
@@ -69,7 +69,7 @@
             trigger: 'axis',
             axisPointer: {
               lineStyle: {
-                color: '#57617B'
+                color: '#000000'
               }
             }
           },
@@ -83,7 +83,7 @@
             right: '4%',
             textStyle: {
               fontSize: 12,
-              color: '#F1F1F3'
+              color: '#000000'
             }
           },
           dataZoom: [{
@@ -94,7 +94,7 @@
             left: "15%",
             right: "15%",
             textStyle: {
-              color: "#ffffff"
+              color: "#000000"
             }
           }, {
             type: 'inside'
@@ -111,7 +111,7 @@
             boundaryGap: false,
             axisLine: {
               lineStyle: {
-                color: '#ffffff'
+                color: "#000000"
               }
             },
             data: timeaxis
@@ -124,7 +124,7 @@
             },
             axisLine: {
               lineStyle: {
-                color: '#ffffff'
+                color: '#000000'
               }
             },
             axisLabel: {
@@ -166,7 +166,8 @@
         option.yAxis[0].max = cap
 
         if(displayKyLl == 1){
-          option.legend.data = ['实际功率','可用功率','理论功率','参照理论功率(测风、测光法)','参照理论功率(样板机法)','参照可用功率(测风、测光法)','参照可用功率(样板机法)']
+          // option.legend.data = ['实际功率','可用功率','理论功率','参照理论功率(测风、测光法)','参照理论功率(样板机法)','参照可用功率(测风、测光法)','参照可用功率(样板机法)']
+          option.legend.data = ['实际功率','可用功率','理论功率']
           option.series.push({
             name: '可用功率',
             type: 'line',
@@ -179,19 +180,19 @@
                 width: 2
               }
             },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
+            // areaStyle: {
+            //   normal: {
+            //     color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+            //       offset: 0,
+            //       color: 'rgba(219, 50, 51, 0.3)'
+            //     }, {
+            //       offset: 0.8,
+            //       color: 'rgba(219, 50, 51, 0)'
+            //     }], false),
+            //     shadowColor: 'rgba(0, 0, 0, 0.1)',
+            //     shadowBlur: 10
+            //   }
+            // },
             itemStyle: {
               normal: {
 
@@ -213,19 +214,19 @@
                 width: 2
               }
             },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
+            // areaStyle: {
+            //   normal: {
+            //     color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+            //       offset: 0,
+            //       color: 'rgba(219, 50, 51, 0.3)'
+            //     }, {
+            //       offset: 0.8,
+            //       color: 'rgba(219, 50, 51, 0)'
+            //     }], false),
+            //     shadowColor: 'rgba(0, 0, 0, 0.1)',
+            //     shadowBlur: 10
+            //   }
+            // },
             itemStyle: {
               normal: {
 
@@ -235,141 +236,143 @@
               }
             },
             data: theorypower
-          },{
-            name: '参照理论功率(测风、测光法)',
-            type: 'line',
-            smooth: true,
-            symbol: 'circle',
-            symbolSize: 5,
-            showSymbol: false,
-            lineStyle: {
-              normal: {
-                width: 2
-              }
-            },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
-            itemStyle: {
-              normal: {
-
-                color: cc.cfgf,
-                borderColor: 'rgba(219,50,51,0.2)',
-                borderWidth: 12
-              }
-            },
-            data: referencePowerByMeasuringpower
-          },{
-            name: '参照理论功率(样板机法)',
-            type: 'line',
-            smooth: true,
-            symbol: 'circle',
-            symbolSize: 5,
-            showSymbol: false,
-            lineStyle: {
-              normal: {
-                width: 2
-              }
-            },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
-            itemStyle: {
-              normal: {
-
-                color: cc.ybjf,
-                borderColor: 'rgba(219,50,51,0.2)',
-                borderWidth: 12
-              }
-            },
-            data: referencePowerBySamplepower
-          },{
-            name: '参照可用功率(测风、测光法)',
-            type: 'line',
-            smooth: true,
-            symbol: 'circle',
-            symbolSize: 5,
-            showSymbol: false,
-            lineStyle: {
-              normal: {
-                width: 2
-              }
-            },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
-            itemStyle: {
-              normal: {
-                color: cc.kycfgf,
-                borderColor: 'rgba(219,50,51,0.2)',
-                borderWidth: 12
-              }
-            },
-            data: ablePowerByMeasuringe
-          },{
-            name: '参照可用功率(样板机法)',
-            type: 'line',
-            smooth: true,
-            symbol: 'circle',
-            symbolSize: 5,
-            showSymbol: false,
-            lineStyle: {
-              normal: {
-                width: 2
-              }
-            },
-            areaStyle: {
-              normal: {
-                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                  offset: 0,
-                  color: 'rgba(219, 50, 51, 0.3)'
-                }, {
-                  offset: 0.8,
-                  color: 'rgba(219, 50, 51, 0)'
-                }], false),
-                shadowColor: 'rgba(0, 0, 0, 0.1)',
-                shadowBlur: 10
-              }
-            },
-            itemStyle: {
-              normal: {
-                color: cc.kyybjf,
-                borderColor: 'rgba(219,50,51,0.2)',
-                borderWidth: 12
-              }
-            },
-            data: ablePowerBySample
-          })
+          }
+          //   {
+          //   name: '参照理论功率(测风、测光法)',
+          //   type: 'line',
+          //   smooth: true,
+          //   symbol: 'circle',
+          //   symbolSize: 5,
+          //   showSymbol: false,
+          //   lineStyle: {
+          //     normal: {
+          //       width: 2
+          //     }
+          //   },
+          //   areaStyle: {
+          //     normal: {
+          //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+          //         offset: 0,
+          //         color: 'rgba(219, 50, 51, 0.3)'
+          //       }, {
+          //         offset: 0.8,
+          //         color: 'rgba(219, 50, 51, 0)'
+          //       }], false),
+          //       shadowColor: 'rgba(0, 0, 0, 0.1)',
+          //       shadowBlur: 10
+          //     }
+          //   },
+          //   itemStyle: {
+          //     normal: {
+          //
+          //       color: cc.cfgf,
+          //       borderColor: 'rgba(219,50,51,0.2)',
+          //       borderWidth: 12
+          //     }
+          //   },
+          //   data: referencePowerByMeasuringpower
+          // },{
+          //   name: '参照理论功率(样板机法)',
+          //   type: 'line',
+          //   smooth: true,
+          //   symbol: 'circle',
+          //   symbolSize: 5,
+          //   showSymbol: false,
+          //   lineStyle: {
+          //     normal: {
+          //       width: 2
+          //     }
+          //   },
+          //   areaStyle: {
+          //     normal: {
+          //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+          //         offset: 0,
+          //         color: 'rgba(219, 50, 51, 0.3)'
+          //       }, {
+          //         offset: 0.8,
+          //         color: 'rgba(219, 50, 51, 0)'
+          //       }], false),
+          //       shadowColor: 'rgba(0, 0, 0, 0.1)',
+          //       shadowBlur: 10
+          //     }
+          //   },
+          //   itemStyle: {
+          //     normal: {
+          //
+          //       color: cc.ybjf,
+          //       borderColor: 'rgba(219,50,51,0.2)',
+          //       borderWidth: 12
+          //     }
+          //   },
+          //   data: referencePowerBySamplepower
+          // },{
+          //   name: '参照可用功率(测风、测光法)',
+          //   type: 'line',
+          //   smooth: true,
+          //   symbol: 'circle',
+          //   symbolSize: 5,
+          //   showSymbol: false,
+          //   lineStyle: {
+          //     normal: {
+          //       width: 2
+          //     }
+          //   },
+          //   areaStyle: {
+          //     normal: {
+          //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+          //         offset: 0,
+          //         color: 'rgba(219, 50, 51, 0.3)'
+          //       }, {
+          //         offset: 0.8,
+          //         color: 'rgba(219, 50, 51, 0)'
+          //       }], false),
+          //       shadowColor: 'rgba(0, 0, 0, 0.1)',
+          //       shadowBlur: 10
+          //     }
+          //   },
+          //   itemStyle: {
+          //     normal: {
+          //       color: cc.kycfgf,
+          //       borderColor: 'rgba(219,50,51,0.2)',
+          //       borderWidth: 12
+          //     }
+          //   },
+          //   data: ablePowerByMeasuringe
+          // },{
+          //   name: '参照可用功率(样板机法)',
+          //   type: 'line',
+          //   smooth: true,
+          //   symbol: 'circle',
+          //   symbolSize: 5,
+          //   showSymbol: false,
+          //   lineStyle: {
+          //     normal: {
+          //       width: 2
+          //     }
+          //   },
+          //   areaStyle: {
+          //     normal: {
+          //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+          //         offset: 0,
+          //         color: 'rgba(219, 50, 51, 0.3)'
+          //       }, {
+          //         offset: 0.8,
+          //         color: 'rgba(219, 50, 51, 0)'
+          //       }], false),
+          //       shadowColor: 'rgba(0, 0, 0, 0.1)',
+          //       shadowBlur: 10
+          //     }
+          //   },
+          //   itemStyle: {
+          //     normal: {
+          //       color: cc.kyybjf,
+          //       borderColor: 'rgba(219,50,51,0.2)',
+          //       borderWidth: 12
+          //     }
+          //   },
+          //   data: ablePowerBySample
+          // }
+        )
         }
         this.chart.setOption(option,true)
       },

+ 21 - 23
ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/index.vue

@@ -48,9 +48,7 @@
               :custom-config="{storage: true, checkMethod: checkColumnMethod}"
               :auto-resize="true"
               highlight-hover-row
-              :header-cell-style="{background:'black',color:'white',border:'white'}"
               max-height="90%"
-              :cell-style="{background:'black',color:'white'}"
               align="center"
               :data="tableData"
               :columns="tableColumn"
@@ -151,36 +149,36 @@ export default {
             { field: 'realValue', title: '实际功率',minWidth:"60"},
             { field: 'ableValue', title: '可用功率',minWidth:"60"},
             { field: 'theoryValue', title: '理论功率',minWidth:"60"},
-            { field: 'referencePowerByMeasuring', title: '参照理论功率(测风、测光法)',minWidth:"60"},
-            { field: 'referencePowerBySample', title: '参照理论功率(样板机法)',minWidth:"60"},
-            { field: 'ablePowerByMeasuring', title: '参照可用功率(测风、测光法)',minWidth:"60"},
-            { field: 'ablePowerBySample', title: '参照可用功率(样板机法)',minWidth:"60"},
+            // { field: 'referencePowerByMeasuring', title: '参照理论功率(测风、测光法)',minWidth:"60"},
+            // { field: 'referencePowerBySample', title: '参照理论功率(样板机法)',minWidth:"60"},
+            // { field: 'ablePowerByMeasuring', title: '参照可用功率(测风、测光法)',minWidth:"60"},
+            // { field: 'ablePowerBySample', title: '参照可用功率(样板机法)',minWidth:"60"},
             { field: 'openCapacity', title: '开机容量',minWidth:"60"},
-            { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
-            { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
-            { field: 'capacity', title: '装机容量',minWidth:"60"},
-            { field: 'onGridNum', title: '并网设备',minWidth:"60"}
+            // { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
+            // { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
+            { field: 'capacity', title: '装机容量',minWidth:"60"}
+            // { field: 'onGridNum', title: '并网设备',minWidth:"60"}
           ]
         }else {
           this.tableColumn = [
             { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
             { field: 'realValue', title: '实际功率',minWidth:"60"},
             { field: 'openCapacity', title: '开机容量',minWidth:"60"},
-            { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
-            { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
-            { field: 'capacity', title: '装机容量',minWidth:"60"},
-            { field: 'onGridNum', title: '并网设备',minWidth:"60"}
+            // { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
+            // { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
+            { field: 'capacity', title: '装机容量',minWidth:"60"}
+            // { field: 'onGridNum', title: '并网设备',minWidth:"60"}
           ]
         }
-        if(this.drawData.abnormalShow == '1'){
-          this.tableColumn .push({ field: 'abnormalOfMeasuring', title: '测风光法的异常值',minWidth:"60"})
-          this.tableColumn .push({ field: 'abnormalOfSample', title: '样板机法的异常值',minWidth:"60"})
-        }
-        if(this.drawData.displaySz == '1'){
-          this.tableColumn .push({ field: 'onSiteObstructed', title: '站内受阻功率',minWidth:"60"})
-          this.tableColumn .push({ field: 'offSiteObstructed', title: '站外受阻功率',minWidth:"60"})
-          this.tableColumn .push({ field: 'abandonmentRates', title: '弃电率指标%',minWidth:"60"})
-        }
+        // if(this.drawData.abnormalShow == '1'){
+        //   this.tableColumn .push({ field: 'abnormalOfMeasuring', title: '测风光法的异常值',minWidth:"60"})
+        //   this.tableColumn .push({ field: 'abnormalOfSample', title: '样板机法的异常值',minWidth:"60"})
+        // }
+        // if(this.drawData.displaySz == '1'){
+        //   this.tableColumn .push({ field: 'onSiteObstructed', title: '站内受阻功率',minWidth:"60"})
+        //   this.tableColumn .push({ field: 'offSiteObstructed', title: '站外受阻功率',minWidth:"60"})
+        //   this.tableColumn .push({ field: 'abandonmentRates', title: '弃电率指标%',minWidth:"60"})
+        // }
         if(!this.drawLoading && !this.tableLoading){
           this.loading = false
         }

+ 1 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PowerStationStatusDataController.java

@@ -74,7 +74,7 @@ public class PowerStationStatusDataController {
    * @param sortOrder 排序
    * @return
    */
-  @GetMapping(value = "/powerStationStatus/{startTime}/{endTime}/{page}/{size}")
+  @GetMapping(value = "/powerStationStatus/{startTime}/{endTime}/{page}/{size}/{stationCode}")
   public ResponseVO findByTimeBetweenForPaging(@PathVariable("startTime") Long startTime,
                                                @PathVariable("endTime") Long endTime,
                                                @PathVariable("page") Integer page,

+ 32 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/DeleteHistoryDataJob.java

@@ -0,0 +1,32 @@
+package com.jiayue.ipfcst.console.job;
+
+import com.jiayue.ipfcst.console.service.DeleteHistoryDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * 删除前15天的历史数据
+ *
+ * @author whc
+ * @version 3.0
+ */
+@Slf4j
+@Service
+@EnableScheduling
+public class DeleteHistoryDataJob {
+  @Autowired
+  DeleteHistoryDataService deleteHistoryData;
+
+  @Scheduled(fixedRate = 86400000)
+  private void delete(){
+    log.info("开始删除15天前的历史数据");
+
+    deleteHistoryData.deleteData();
+
+    log.info("15天前的历史数据已删除");
+  }
+}

+ 18 - 7
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/ReceiveDataJob.java

@@ -1,15 +1,18 @@
 package com.jiayue.ipfcst.console.job;
 
+import com.jiayue.ipfcst.console.service.ReceiveAllDataService;
+import com.jiayue.ipfcst.console.service.ReceiveAllTypeService;
 import com.jiayue.ipfcst.console.service.ReceiveDataService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 
 /**
- * 天气预报下载 停用  现已由外网下发不主动下载
+ * 接收数据定时任务类
  *
  * @author whc
  * @version 3.0
@@ -21,15 +24,23 @@ public class ReceiveDataJob {
 
   @Autowired
   private ReceiveDataService receiveDataService;
-
-
-  @Scheduled(fixedDelay = 60000)
+  @Autowired
+  private ReceiveAllDataService receiveAllDataService;
+  @Autowired
+  private ReceiveAllTypeService allTypeService;
+  @Value("${receive.mode}")
+  private String mode;
+  @Scheduled(fixedRate = 60000)
   public void receiveData() {
 
     log.info("开始向绿能数据中心请求数据");
-
-    this.receiveDataService.receive();
-
+    if(mode.equals("slice")){
+      //切片查询
+      this.allTypeService.receive();
+    }else{
+      //通用接口查询
+      this.receiveDataService.receive();
+    }
     log.info("数据请求结束");
 
   }

+ 48 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DeleteHistoryDataService.java

@@ -0,0 +1,48 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.data.repository.*;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import lombok.extern.slf4j.Slf4j;
+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.util.Date;
+
+
+@Service
+@Slf4j
+
+public class DeleteHistoryDataService extends BaseService {
+  @Autowired
+  WeatherStationStatusDataRepository weatherStationStatusDataRepository;
+  @Autowired
+  InverterStatusDataRepository inverterStatusDataRepository;
+  @Autowired
+  WindTowerStatusDataRepository windTowerStatusDataRepository;
+  @Autowired
+  WindTurbineStatusDataRepository windTurbineStatusDataRepository;
+  @Autowired
+  ForecastPowerShortTermHisRepository forecastPowerShortTermHisRepository;
+
+
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void deleteData(){
+    try{
+      Date date = new Date();
+      long time = DateMomentUtil.getDayStartTime(date.getTime());
+      long startTime = time - 60 * 60 * 24 * 1000 * 15;
+      Date dateTime = new Date(startTime);
+      forecastPowerShortTermHisRepository.deleteByGenDateBefore(dateTime);
+      weatherStationStatusDataRepository.deleteByTimeBefore(dateTime);
+      inverterStatusDataRepository.deleteByTimeBefore(dateTime);
+      windTowerStatusDataRepository.deleteByTimeBefore(dateTime);
+      windTurbineStatusDataRepository.deleteByTimeBefore(dateTime);
+    }catch (RuntimeException e){
+      log.info("执行删除历史数据定时任务时报错",e);
+    }
+
+  }
+}

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

@@ -340,6 +340,7 @@ public class PowerStationDataPacker {
    * @return {@link PowerStationStatusData}
    */
   public PowerStationStatusData packageData(BigDecimal realPower) {
+    log.info("{}传入的实际功率为:{}",electricField.getName(),realPower);
     PowerStationStatusData powerStationStatusData = new PowerStationStatusData();
     try {
       powerStationStatusData.setStationCode(electricField.getStationCode());

+ 55 - 60
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java

@@ -220,72 +220,67 @@ public class PowerStationStatusDataService extends BaseService {
       }
     }
 
-    String displayKyLl = "0";
-    SysParameter sysParameter = sysParameterRepository.findBySysKeyEquals("DISPLAY_KY_LL");
-
-    if (sysParameter != null && sysParameter.getSysValue().equals("1")) {
-      displayKyLl = "1";
-
-      List<BigDecimal> ableValue = checkList.stream().map(PowerStationStatusData::getAbleValue).collect(Collectors.toList());
-      List<BigDecimal> theoryValue = checkList.stream().map(PowerStationStatusData::getTheoryValue).collect(Collectors.toList());
-      List<BigDecimal> referencePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getReferencePowerByMeasuring).collect(Collectors.toList());
-      List<BigDecimal> referencePowerBySample = checkList.stream().map(PowerStationStatusData::getReferencePowerBySample).collect(Collectors.toList());
-      for (BigDecimal b : ableValue) {
-        if (b.compareTo(nullValue) == 0) {
-          ableValueDatas.add(null);
-        } else {
-          ableValueDatas.add(b.floatValue());
-        }
-      }
-      for (BigDecimal b : theoryValue) {
-        if (b.compareTo(nullValue) == 0) {
-          theoryValueDatas.add(null);
-        } else {
-          theoryValueDatas.add(b.floatValue());
-        }
-      }
+    String displayKyLl = "1";
 
-      for (BigDecimal b : referencePowerByMeasuring) {
-        if (b.compareTo(nullValue) == 0) {
-          referencePowerByMeasuringDatas.add(null);
-        } else {
-          referencePowerByMeasuringDatas.add(b.floatValue());
-        }
+    List<BigDecimal> ableValue = checkList.stream().map(PowerStationStatusData::getAbleValue).collect(Collectors.toList());
+    List<BigDecimal> theoryValue = checkList.stream().map(PowerStationStatusData::getTheoryValue).collect(Collectors.toList());
+//    List<BigDecimal> referencePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getReferencePowerByMeasuring).collect(Collectors.toList());
+//    List<BigDecimal> referencePowerBySample = checkList.stream().map(PowerStationStatusData::getReferencePowerBySample).collect(Collectors.toList());
+    for (BigDecimal b : ableValue) {
+      if (b.compareTo(nullValue) == 0) {
+        ableValueDatas.add(null);
+      } else {
+        ableValueDatas.add(b.floatValue());
       }
-
-      for (BigDecimal b : referencePowerBySample) {
-        if (b.compareTo(nullValue) == 0) {
-          referencePowerBySampleDatas.add(null);
-        } else {
-          referencePowerBySampleDatas.add(b.floatValue());
-        }
+    }
+    for (BigDecimal b : theoryValue) {
+      if (b.compareTo(nullValue) == 0) {
+        theoryValueDatas.add(null);
+      } else {
+        theoryValueDatas.add(b.floatValue());
       }
+    }
 
-      List<BigDecimal> ablePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getAblePowerByMeasuring).collect(Collectors.toList());
-      List<BigDecimal> ablePowerBySample = checkList.stream().map(PowerStationStatusData::getAblePowerBySample).collect(Collectors.toList());
-
-      for (BigDecimal b : ablePowerByMeasuring) {
-        if (b == null || b.compareTo(nullValue) == 0) {
-          ablePowerByMeasuringDatas.add(null);
-        } else {
-          ablePowerByMeasuringDatas.add(b.floatValue());
-        }
+//    for (BigDecimal b : referencePowerByMeasuring) {
+//      if (b.compareTo(nullValue) == 0) {
+//        referencePowerByMeasuringDatas.add(null);
+//      } else {
+//        referencePowerByMeasuringDatas.add(b.floatValue());
+//      }
+//    }
+//
+//    for (BigDecimal b : referencePowerBySample) {
+//      if (b.compareTo(nullValue) == 0) {
+//        referencePowerBySampleDatas.add(null);
+//      } else {
+//        referencePowerBySampleDatas.add(b.floatValue());
+//      }
+//    }
+
+    List<BigDecimal> ablePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getAblePowerByMeasuring).collect(Collectors.toList());
+    List<BigDecimal> ablePowerBySample = checkList.stream().map(PowerStationStatusData::getAblePowerBySample).collect(Collectors.toList());
+
+    for (BigDecimal b : ablePowerByMeasuring) {
+      if (b == null || b.compareTo(nullValue) == 0) {
+        ablePowerByMeasuringDatas.add(null);
+      } else {
+        ablePowerByMeasuringDatas.add(b.floatValue());
       }
-      for (BigDecimal b : ablePowerBySample) {
-        if (b == null || b.compareTo(nullValue) == 0) {
-          ablePowerBySampleDatas.add(null);
-        } else {
-          ablePowerBySampleDatas.add(b.floatValue());
-        }
+    }
+    for (BigDecimal b : ablePowerBySample) {
+      if (b == null || b.compareTo(nullValue) == 0) {
+        ablePowerBySampleDatas.add(null);
+      } else {
+        ablePowerBySampleDatas.add(b.floatValue());
       }
-      map.put("ablePowerByMeasuringDatas", ablePowerByMeasuringDatas);
-      map.put("ablePowerBySampleDatas", ablePowerBySampleDatas);
-
-      map.put("ableValueDatas", ableValueDatas);
-      map.put("theoryValueDatas", theoryValueDatas);
-      map.put("referencePowerByMeasuringDatas", referencePowerByMeasuringDatas);
-      map.put("referencePowerBySampleDatas", referencePowerBySampleDatas);
     }
+//    map.put("ablePowerByMeasuringDatas", ablePowerByMeasuringDatas);
+//    map.put("ablePowerBySampleDatas", ablePowerBySampleDatas);
+
+    map.put("ableValueDatas", ableValueDatas);
+    map.put("theoryValueDatas", theoryValueDatas);
+//    map.put("referencePowerByMeasuringDatas", referencePowerByMeasuringDatas);
+//    map.put("referencePowerBySampleDatas", referencePowerBySampleDatas);
 
 
     String displaySz = "0";
@@ -324,7 +319,7 @@ public class PowerStationStatusDataService extends BaseService {
   public Map<String, Object> findByTimeBetweenForContrast(Date startTime, Date endTime, Long timeStep, String stationCode) {
     Map<String, Object> map = new HashMap<>();
     List<PowerStationStatusData> list = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(startTime, endTime, stationCode);
-    
+
     long startTimeLong = startTime.getTime();
     long endTimeLong = endTime.getTime();
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 411 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveAllDataService.java

@@ -0,0 +1,411 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.*;
+import com.jiayue.ipfcst.common.data.repository.*;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import com.jiayue.ipfcst.console.util.RedisUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 接收数据service类 切片查询 按场站+设备类型查询
+ *
+ * @author whc
+ */
+@Service
+@Slf4j
+public class ReceiveAllDataService extends BaseService {
+  @Autowired
+  ElectricFieldService electricFieldService;
+  @Autowired
+  WindTowerInfoService windTowerInfoService;
+  @Autowired
+  WindTurbineInfoService windTurbineInfoService;
+  @Autowired
+  WeatherStationInfoService weatherStationInfoService;
+  @Autowired
+  InverterInfoService inverterInfoService;
+  @Autowired
+  DataPointService dataPointService;
+  @Autowired
+  WeatherStationStatusDataRepository weatherStationStatusDataRepository;
+  @Autowired
+  InverterStatusDataRepository inverterStatusDataRepository;
+  @Autowired
+  WindTurbineStatusDataRepository windTurbineStatusDataRepository;
+  @Autowired
+  WindTowerStatusDataRepository windTowerStatusDataRepository;
+  @Autowired
+  RedisUtils redisUtils;
+  @Autowired
+  EquipmentAttributeService equipmentAttributeService;
+  @Autowired
+  PowerStationStatusDataRepository powerStationStatusDataRepository;
+  @Autowired
+  PowerStationDataPackerContainer powerStationDataPackerContainer;
+  @Autowired
+  SysAlarmService sysAlarmService;
+  @Value("${receive.ip}")
+  private String ip;
+  @Value("${receive.port}")
+  private  String port;
+  @Value("${receive.path}")
+  private  String path;
+  @Value("${receive.mode}")
+  private String mode;
+  private  final String Active = "activePower";
+
+  //请求超时时间,这个时间定义了socket读数据的超时时间,也就是连接到服务器之后到从服务器获取响应数据需要等待的时间,发生超时,会抛出SocketTimeoutException异常。
+  private static final int SOCKET_TIME_OUT = 5000;
+  //连接超时时间,这个时间定义了通过网络与服务器建立连接的超时时间,也就是取得了连接池中的某个连接之后到接通目标url的连接等待时间。发生超时,会抛出ConnectionTimeoutException异常
+  private static final int CONNECT_TIME_OUT = 3000;
+
+
+
+  public void receive() {
+    List<ElectricField> electricFieldList = electricFieldService.getAll();
+    long endTime =  DateTimeUtil.getCurrentTimeForMinute().getTime();
+    //每个场站请求一次
+    for (ElectricField electricField : electricFieldList) {
+      log.info(electricField.getName() + "开始请求数据");
+      try {
+
+        //切片查询
+        if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
+          //按设备类型请求
+          List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.get(electricField.getStationCode());
+          List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
+          //气象站
+          if(!weatherStationInfoList.isEmpty()){
+            //设备编号
+            String equipmentNo = "";
+            //测点id
+            String sensorIds = "";
+            List<DataPoint> dataPointList;
+            for (WeatherStationInfo weatherStationInfo : weatherStationInfoList) {
+              equipmentNo += weatherStationInfo.getEquipmentNo()+",";
+            }
+            dataPointList = dataPointService.getByEquipmentType(weatherStationInfoList.get(0).getEquipmentType());
+            for (DataPoint dataPoint : dataPointList){
+              sensorIds += dataPoint.getMeasuringPoint()+",";
+            }
+            equipmentNo = equipmentNo.substring(0,equipmentNo.length()-1);
+            sensorIds = sensorIds.substring(0,sensorIds.length()-1);
+            map(electricField,endTime,equipmentNo,weatherStationInfoList.get(0).getEquipmentType(),sensorIds);
+          }
+
+          //逆变器
+          if (!inverterInfoList.isEmpty()){
+            //设备编号
+            String equipmentNo = "";
+            //测点id
+            String sensorIds = "";
+            List<DataPoint> dataPointList;
+            for (InverterInfo inverterInfo : inverterInfoList) {
+              equipmentNo += inverterInfo.getEquipmentNo()+",";
+             }
+            dataPointList = dataPointService.getByEquipmentType(inverterInfoList.get(0).getEquipmentType());
+            for (DataPoint dataPoint : dataPointList){
+              sensorIds += dataPoint.getMeasuringPoint()+",";
+            }
+            equipmentNo = equipmentNo.substring(0,equipmentNo.length()-1);
+            sensorIds = sensorIds.substring(0,sensorIds.length()-1);
+            map(electricField, endTime,equipmentNo,inverterInfoList.get(0).getEquipmentType(),sensorIds);
+
+          }
+
+        } else {
+          List<WindTowerInfo> windTowerInfoList = windTowerInfoService.get(electricField.getStationCode());
+
+          List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
+          //测风塔
+          if(!windTowerInfoList.isEmpty()){
+            //设备编号
+            String equipmentNo = "";
+            //测点id
+            String sensorIds = "";
+            List<DataPoint> dataPointList;
+            for (WindTowerInfo windTowerInfo : windTowerInfoList) {
+              equipmentNo += windTowerInfo.getEquipmentNo()+",";
+            }
+            dataPointList = dataPointService.getByEquipmentType(windTowerInfoList.get(0).getEquipmentType());
+            for (DataPoint dataPoint : dataPointList){
+              sensorIds += dataPoint.getMeasuringPoint()+",";
+            }
+            equipmentNo = equipmentNo.substring(0,equipmentNo.length()-1);
+            sensorIds = sensorIds.substring(0,sensorIds.length()-1);
+            map(electricField,endTime,equipmentNo,windTowerInfoList.get(0).getEquipmentType(),sensorIds);
+          }
+          //风机
+          if(!windTurbineInfoList.isEmpty()){
+            //设备编号
+            String equipmentNo = "";
+            //测点id
+            String sensorIds = "";
+            List<DataPoint> dataPointList;
+            for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
+              equipmentNo += windTurbineInfo.getEquipmentNo()+",";
+            }
+            dataPointList = dataPointService.getByEquipmentType(windTurbineInfoList.get(0).getEquipmentType());
+            for (DataPoint dataPoint : dataPointList){
+              sensorIds += dataPoint.getMeasuringPoint()+",";
+            }
+            equipmentNo = equipmentNo.substring(0,equipmentNo.length()-1);
+            sensorIds = sensorIds.substring(0,sensorIds.length()-1);
+            map(electricField,endTime,equipmentNo,windTurbineInfoList.get(0).getEquipmentType(),sensorIds);
+          }
+        }
+        savePowerStationStatusData(electricField);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  private void map(ElectricField electricField, Long endTime, String equipmentNo,EquipmentTypeEnum equipmentType,String sensorIds) {
+    HashMap<String, Object> paramMap = new HashMap<>();
+    paramMap.put("deviceIds", equipmentNo);
+    paramMap.put("timestamp", endTime);
+    paramMap.put("sensorIds",sensorIds);
+    log.info(String.valueOf(paramMap));
+    String body = httpClient(paramMap,electricField);
+    log.info(body);
+    AnalysisData(body, equipmentType, electricField);
+  }
+
+  /**
+   * 解析数据
+   *
+   * @param body          所有数据
+   * @param equipmentType 设备类型
+   * @param electricField 场站对象
+   */
+  public void AnalysisData(String body, EquipmentTypeEnum equipmentType, ElectricField electricField) {
+    try {
+      List<DataPoint> dataPointList = dataPointService.getByEquipmentType(equipmentType);
+      JSONObject jsonObject= JSON.parseObject(body);
+      JSONArray jsonResults = (JSONArray) jsonObject.get("results");
+      if (!jsonResults.isEmpty()){
+        for(int i = 0 ; i < jsonResults.size() ; i ++){
+          //results
+          JSONObject jsonObj = jsonResults.getJSONObject(i);
+          //设备id
+          String equipmentId  = (String) jsonObj.get("deviceId");
+          //rows
+          JSONArray jsonRows = (JSONArray) jsonObj.get("rows");
+          //所有设备点位
+          JSONArray sensorIds = (JSONArray) jsonObj.get("sensorIds");
+          JSONObject values;
+          Map<String, String> map = new HashMap<>();
+          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+          if (!jsonRows.isEmpty()){
+            values = jsonRows.getJSONObject(0);
+            //时间戳
+            String time = values.getString("timestamp");
+            //所有数据
+            JSONArray jsonValues = (JSONArray) values.get("values");
+            long timestamp = Long.parseLong(time);
+            map.put("stationCode",electricField.getStationCode());
+            map.put("equipmentId", equipmentId);
+            map.put("time", simpleDateFormat.format(timestamp));
+            for (DataPoint dataPoint : dataPointList) {
+              for (int j = 0; j < sensorIds.size(); j++) {
+                if (dataPoint.getMeasuringPoint().equals(sensorIds.get(j))) {
+                  if(jsonValues.get(j) == null ){
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), "-99");
+                  }else{
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), jsonValues.get(j).toString());
+                  }
+                }
+              }
+            }
+            String STATUS = "status";
+            switch (map.get(STATUS)) {
+              case "1.00":
+              case "true":
+                //运行
+                map.put(STATUS, "1");
+                break;
+              case "2.00":
+                //待机
+                map.put(STATUS, "2");
+                break;
+              case "3.00":
+                //停用
+                map.put(STATUS, "3");
+                break;
+              case "4.00":
+              case "false":
+                //通讯中断
+                map.put(STATUS, "4");
+                break;
+              case "5.00":
+              case "-99":
+                map.put(STATUS, "5");
+                break;
+              default:
+                break;
+            }
+
+            String ap = map.get(Active);
+            switch(equipmentType.getCode()){
+              case 1:
+                //气象站
+                redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
+                WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
+                weatherStationStatusDataRepository.save(weatherStationStatusData);
+                log.info(map.get("time")+"qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+                break;
+              case 2:
+                //逆变器
+                if (ap != null && map.get("electricalCurrent") != null) {
+                  //有功
+                  BigDecimal activePower = new BigDecimal(ap);
+                  //电流
+                  BigDecimal electricalCurrent = new BigDecimal(map.get("electricalCurrent"));
+                  //有功/电流=电压
+                  BigDecimal voltage = activePower.divide(electricalCurrent, 2, BigDecimal.ROUND_HALF_UP);
+                  map.put("voltage", voltage.toString());
+                }
+                redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
+                InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
+                inverterStatusDataRepository.save(inverterStatusData);
+                log.info(map.get("time")+"nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+                break;
+              case 3:
+                redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
+                WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
+                windTurbineStatusDataRepository.save(windTurbineStatusData);
+                log.info("fj-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+                break;
+              case 4:
+                redisUtils.hmset("cft-" + electricField.getStationCode() + "-" + equipmentId, map);
+                WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
+                windTowerStatusDataRepository.save(windTowerStatusData);
+                log.info("cft-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+                break;
+              default:
+                break;
+            }
+          }else {
+            log.info(electricField.getStationCode()+ "-" +equipmentType.getMessage() + "-" + equipmentId+"无数据,不进行任何操作");
+          }
+        }
+
+      }else {
+        log.info(electricField.getStationCode()+ "-" +equipmentType.getMessage() + "-" +"对方没有该类型设备,请核对设备信息");
+      }
+    } catch (Exception e) {
+      log.info(electricField.getName()+equipmentType.getMessage()+"程序解析数据异常");
+      // 进行告警
+      String errorInfo = electricField.getStationCode()+equipmentType.getMessage()+"程序解析数据异常";
+      String name = "程序解析数据异常";
+      String describe = "";
+      String solution = "";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, name, describe, errorInfo, solution,electricField.getStationCode());
+      e.printStackTrace();
+    }
+  }
+
+  /**
+   * 发http请求
+   * @param paramMap 参数
+   * @return 返回的数据
+   */
+  public String httpClient( HashMap<String, Object> paramMap,ElectricField electricField){
+    String body = "";
+    try{
+      CloseableHttpClient  httpClient = HttpClientBuilder.create().build();
+      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path+mode);
+
+      StringEntity entity = new StringEntity(JSON.toJSONString(paramMap),"UTF-8");
+      httpPost.setEntity(entity);
+      //设置请求超时时间,链接超时时间
+      RequestConfig reqConfig = RequestConfig.custom().setSocketTimeout(SOCKET_TIME_OUT).setConnectTimeout(CONNECT_TIME_OUT).build();
+      httpPost.setConfig(reqConfig);
+      httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
+      CloseableHttpResponse response;
+      response = httpClient.execute(httpPost);
+      HttpEntity responseEntity = response.getEntity();
+      body = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
+    }catch (RuntimeException | IOException e){
+      String errorInfo = "发送http请求数据异常";
+      log.info(errorInfo);
+      log.info("所用线程"+Thread.currentThread().getName());
+      log.info("停止请求数据");
+      // 进行告警
+      String describe = "";
+      String solution = "停止请求数据";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, errorInfo, describe, errorInfo, solution,electricField.getStationCode());
+
+      Thread.currentThread().stop();
+
+
+    }
+    return body;
+  }
+
+  public void savePowerStationStatusData(ElectricField electricField) {
+    try {
+      log.info("开始计算实际功率");
+      BigDecimal pssd = new BigDecimal("0");
+      if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
+        List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
+        for (InverterInfo inverterInfo : inverterInfoList) {
+          Map<String, String> getMap = redisUtils.hgetall("nbq-" + electricField.getStationCode() + "-" + inverterInfo.getId());
+          String activePower = getMap.get(Active);
+          if (activePower != null) {
+            pssd = pssd.add(new BigDecimal(activePower));
+          }
+        }
+      } else {
+        List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
+        for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
+          Map<String, String> getMap = redisUtils.hgetall("fj-" + electricField.getStationCode() + "-" + windTurbineInfo.getId());
+          String activePower = getMap.get(Active);
+          if (activePower != null) {
+            pssd = pssd.add(new BigDecimal(activePower));
+          }
+        }
+      }
+      if (pssd.compareTo(new BigDecimal("0")) > 0) {
+        pssd = pssd.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
+      }
+      PowerStationStatusData p = powerStationDataPackerContainer.getDataPacker(electricField.getStationCode()).packageData(pssd);
+      powerStationStatusDataRepository.save(p);
+      //对象转map
+      Map<String, String> map    = JSON.parseObject(JSON.toJSONString(p), new TypeReference<Map<String, String>>() {
+      });
+      redisUtils.hmset("power-" + electricField.getStationCode(), map);
+      log.info("实际功率结束");
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+}

+ 527 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveAllTypeService.java

@@ -0,0 +1,527 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.core.util.JsonBeanUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.*;
+import com.jiayue.ipfcst.common.data.repository.*;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import com.jiayue.ipfcst.console.util.RedisUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 接收数据service类 切片查询 按设备类型查询
+ *
+ * @author whc
+ */
+@Service
+@Slf4j
+public class ReceiveAllTypeService extends BaseService {
+  @Autowired
+  ElectricFieldService electricFieldService;
+  @Autowired
+  WindTowerInfoService windTowerInfoService;
+  @Autowired
+  WindTurbineInfoService windTurbineInfoService;
+  @Autowired
+  WeatherStationInfoService weatherStationInfoService;
+  @Autowired
+  InverterInfoService inverterInfoService;
+  @Autowired
+  DataPointService dataPointService;
+  @Autowired
+  WeatherStationStatusDataRepository weatherStationStatusDataRepository;
+  @Autowired
+  InverterStatusDataRepository inverterStatusDataRepository;
+  @Autowired
+  WindTurbineStatusDataRepository windTurbineStatusDataRepository;
+  @Autowired
+  WindTowerStatusDataRepository windTowerStatusDataRepository;
+  @Autowired
+  RedisUtils redisUtils;
+  @Autowired
+  EquipmentAttributeService equipmentAttributeService;
+  @Autowired
+  PowerStationStatusDataRepository powerStationStatusDataRepository;
+  @Autowired
+  PowerStationDataPackerContainer powerStationDataPackerContainer;
+  @Autowired
+  SysAlarmService sysAlarmService;
+  @Value("${receive.ip}")
+  private String ip;
+  @Value("${receive.port}")
+  private  String port;
+  @Value("${receive.path}")
+  private  String path;
+  @Value("${receive.mode}")
+  private String mode;
+  private  final String Active = "activePower";
+
+  //请求超时时间,这个时间定义了socket读数据的超时时间,也就是连接到服务器之后到从服务器获取响应数据需要等待的时间,发生超时,会抛出SocketTimeoutException异常。
+  private static final int SOCKET_TIME_OUT = 5000;
+  //连接超时时间,这个时间定义了通过网络与服务器建立连接的超时时间,也就是取得了连接池中的某个连接之后到接通目标url的连接等待时间。发生超时,会抛出ConnectionTimeoutException异常
+  private static final int CONNECT_TIME_OUT = 3000;
+
+
+
+  public void receive() {
+    long endTime = DateTimeUtil.getCurrentTimeForMinute().getTime();
+    try {
+      //按设备类型请求 气象站因为检修状态测点原因使用通用接口单独请求数据
+      List<InverterInfo> inverterInfoList = inverterInfoService.getAll();
+      List<WindTowerInfo> windTowerInfoList = windTowerInfoService.getAll();
+      List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getAll();
+      //逆变器
+      if (!inverterInfoList.isEmpty()) {
+        //设备编号
+        List<String> equipmentNo =new ArrayList<>();
+        //测点id
+        List<String> sensorIds =new ArrayList<>();
+        List<DataPoint> dataPointList;
+        for (InverterInfo inverterInfo : inverterInfoList) {
+          equipmentNo.add(inverterInfo.getEquipmentNo());
+        }
+        dataPointList = dataPointService.getByEquipmentType(inverterInfoList.get(0).getEquipmentType());
+        for (DataPoint dataPoint : dataPointList) {
+          sensorIds.add(dataPoint.getMeasuringPoint());
+        }
+        map(endTime, equipmentNo, inverterInfoList.get(0).getEquipmentType(), sensorIds);
+      }
+      //测风塔
+      if (!windTowerInfoList.isEmpty()) {
+        //设备编号
+        List<String> equipmentNo =new ArrayList<>();
+        //测点id
+        List<String> sensorIds =new ArrayList<>();
+        List<DataPoint> dataPointList;
+        for (WindTowerInfo windTowerInfo : windTowerInfoList) {
+          equipmentNo.add(windTowerInfo.getEquipmentNo());
+        }
+        dataPointList = dataPointService.getByEquipmentType(windTowerInfoList.get(0).getEquipmentType());
+        for (DataPoint dataPoint : dataPointList) {
+          sensorIds.add(dataPoint.getMeasuringPoint());
+        }
+        map(endTime, equipmentNo, windTowerInfoList.get(0).getEquipmentType(), sensorIds);
+      }
+      //风机
+      if (!windTurbineInfoList.isEmpty()) {
+        //设备编号
+        List<String> equipmentNo =new ArrayList<>();
+        //测点id
+        List<String> sensorIds =new ArrayList<>();
+        List<DataPoint> dataPointList;
+        for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
+          equipmentNo.add(windTurbineInfo.getEquipmentNo());
+        }
+        dataPointList = dataPointService.getByEquipmentType(windTurbineInfoList.get(0).getEquipmentType());
+        for (DataPoint dataPoint : dataPointList) {
+          sensorIds.add(dataPoint.getMeasuringPoint());
+        }
+        map( endTime, equipmentNo, windTurbineInfoList.get(0).getEquipmentType(), sensorIds);
+      }
+      //该接口拿不到气象站检修状态数据,只能通过通用端口拿取数据
+      receiveQXZZT(endTime);
+      //计算实际功率
+      savePowerStationStatusData();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void map(Long endTime, List<String> equipmentNo,EquipmentTypeEnum equipmentType,List<String> sensorIds) {
+    HashMap<String, Object> paramMap = new HashMap<>();
+    paramMap.put("deviceIds", equipmentNo);
+    paramMap.put("timestamp", endTime);
+    paramMap.put("sensorIds",sensorIds);
+    log.debug(JSON.toJSONString(paramMap));
+    String body = httpClient(paramMap);
+    log.debug(body);
+    AnalysisData(body, equipmentType);
+  }
+
+  /**
+   * 解析数据
+   *
+   * @param body          所有数据
+   * @param equipmentType 设备类型
+   */
+  public void AnalysisData(String body, EquipmentTypeEnum equipmentType) {
+    try {
+      List<ElectricField> electricFieldList = electricFieldService.getAll();
+      List<DataPoint> dataPointList = dataPointService.getByEquipmentType(equipmentType);
+      JSONObject jsonObject= JSON.parseObject(body);
+      JSONArray jsonResults = (JSONArray) jsonObject.get("results");
+      if (!jsonResults.isEmpty()){
+        for(int i = 0 ; i < jsonResults.size() ; i ++){
+          //results
+          JSONObject jsonObj = jsonResults.getJSONObject(i);
+          //设备id
+          String equipmentId  = (String) jsonObj.get("deviceId");
+          //rows
+          JSONArray jsonRows = (JSONArray) jsonObj.get("rows");
+          //所有设备点位
+          JSONArray sensorIds = (JSONArray) jsonObj.get("sensorIds");
+          JSONObject values;
+          Map<String, String> map = new HashMap<>();
+          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+          if (!jsonRows.isEmpty()){
+            values = jsonRows.getJSONObject(0);
+            //时间戳
+            String time = values.getString("timestamp");
+            //所有数据
+            JSONArray jsonValues = (JSONArray) values.get("values");
+            //青海场站id
+            String stationId = jsonObj.getString("stationId");
+            //嘉越场站编号
+            String electricFieldId = "";
+            for(ElectricField electricField : electricFieldList){
+             if(electricField.getElectricFieldId().equals(stationId)){
+               electricFieldId = electricField.getStationCode();
+             }
+            }
+            long timestamp = Long.parseLong(time);
+            //通过接收到的id找出编号
+            map.put("stationCode",electricFieldId);
+            map.put("equipmentId", equipmentId);
+            map.put("time", simpleDateFormat.format(timestamp));
+            for (DataPoint dataPoint : dataPointList) {
+              for (int j = 0; j < sensorIds.size(); j++) {
+                if (dataPoint.getMeasuringPoint().equals(sensorIds.get(j))) {
+                  if(jsonValues.get(j) == null ){
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), "-99");
+                  }else{
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), jsonValues.get(j).toString());
+                  }
+                }
+              }
+            }
+            String STATUS = "status";switch (map.get(STATUS)) {
+              case "1.00": case "1.0": case "true":
+                //运行
+                map.put(STATUS, "1");
+                break; case "2.00": case "2.0"://待机
+                map.put(STATUS, "2");
+                break; case "3.00": case "3.0"://停用
+                map.put(STATUS, "3");
+                break; case "4.00": case "4.0": case "false"://通讯中断
+                map.put(STATUS, "4");
+                break; case "5.00": case "5.0": case "-99": map.put(STATUS, "5");
+                break;
+                default: break;
+            }
+            String ap = map.get(Active);
+            switch(equipmentType.getCode()){
+              case 2:
+                //逆变器
+                if (ap != null && map.get("electricalCurrent") != null) {
+                  //有功
+                  BigDecimal activePower = new BigDecimal(ap);
+                  //电流
+                  BigDecimal electricalCurrent = new BigDecimal(map.get("electricalCurrent"));
+                  BigDecimal voltage;
+                  if(!electricalCurrent.equals(new BigDecimal(0))){
+                    map.put("voltage","0");
+                  }else{
+                    //有功/电流=电压
+                    voltage = activePower.divide(electricalCurrent, 2, BigDecimal.ROUND_HALF_UP);
+                    map.put("voltage", voltage.toString());
+                  }
+
+                }
+                redisUtils.hmset("nbq-" + electricFieldId + "-" + equipmentId, map);
+                InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
+                inverterStatusDataRepository.save(inverterStatusData);
+                log.info(map.get("time")+"nbq-" + electricFieldId + "-" + equipmentId+"已存入");
+                break;
+              case 3:
+                redisUtils.hmset("fj-" + electricFieldId + "-" + equipmentId, map);
+                WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
+                windTurbineStatusDataRepository.save(windTurbineStatusData);
+                log.info("fj-" + electricFieldId + "-" + equipmentId+"已存入");
+                break;
+              case 4:
+                redisUtils.hmset("cft-" + electricFieldId + "-" + equipmentId, map);
+                WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
+                windTowerStatusDataRepository.save(windTowerStatusData);
+                log.info("cft-" + electricFieldId + "-" + equipmentId+"已存入");
+                break;
+              default:
+                break;
+            }
+          }else {
+            log.info(equipmentType.getMessage() + "-" + equipmentId+"无数据,不进行任何操作");
+          }
+        }
+      }else {
+        log.info(equipmentType.getMessage() + "-" +"对方没有该类型设备,请核对设备信息");
+      }
+    } catch (Exception e) {
+      log.info(equipmentType.getMessage()+"类型数据程序解析数据异常");
+      // 进行告警
+      String errorInfo = equipmentType.getMessage()+"类型数据程序解析数据异常";
+      String name = "程序解析数据异常";
+      String describe = "";
+      String solution = "";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, name, describe, errorInfo, solution);
+      e.printStackTrace();
+    }
+  }
+
+  /**
+   * 发http请求
+   * @param paramMap 参数
+   * @return 返回的数据
+   */
+  public String httpClient( HashMap<String, Object> paramMap){
+    String body = "";
+    try{
+      CloseableHttpClient  httpClient = HttpClientBuilder.create().build();
+      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path+mode);
+
+      StringEntity entity = new StringEntity(JSON.toJSONString(paramMap),"UTF-8");
+      httpPost.setEntity(entity);
+      //设置请求超时时间,链接超时时间
+      RequestConfig reqConfig = RequestConfig.custom().setSocketTimeout(SOCKET_TIME_OUT).setConnectTimeout(CONNECT_TIME_OUT).build();
+      httpPost.setConfig(reqConfig);
+      httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
+      CloseableHttpResponse response;
+      response = httpClient.execute(httpPost);
+      HttpEntity responseEntity = response.getEntity();
+      body = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
+    }catch (RuntimeException | IOException e){
+      String errorInfo = "发送http请求数据异常";
+      log.info(errorInfo);
+      log.info("所用线程"+Thread.currentThread().getName());
+      log.info("停止请求数据");
+      // 进行告警
+      String describe = "";
+      String solution = "停止请求数据";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, errorInfo, describe, errorInfo, solution);
+      Thread.currentThread().stop();
+    }
+    return body;
+  }
+
+  public void savePowerStationStatusData() {
+    List<ElectricField> electricFieldList = electricFieldService.getAll();
+    for(ElectricField electricField:electricFieldList){
+      try {
+        log.info("开始计算实际功率");
+        BigDecimal pssd = new BigDecimal("0");
+        if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
+          List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
+          for (InverterInfo inverterInfo : inverterInfoList) {
+            Map<String, String> getMap = redisUtils.hgetall("nbq-" + electricField.getStationCode() + "-" + inverterInfo.getId());
+            String activePower = getMap.get(Active);
+            if (activePower != null) {
+              pssd = pssd.add(new BigDecimal(activePower));
+            }
+          }
+        } else {
+          List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
+          for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
+            Map<String, String> getMap = redisUtils.hgetall("fj-" + electricField.getStationCode() + "-" + windTurbineInfo.getId());
+            String activePower = getMap.get(Active);
+            if (activePower != null) {
+              pssd = pssd.add(new BigDecimal(activePower));
+            }
+          }
+        }
+        if (pssd.compareTo(new BigDecimal("0")) > 0) {
+          pssd = pssd.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
+        }
+        PowerStationStatusData p = powerStationDataPackerContainer.getDataPacker(electricField.getStationCode()).packageData(pssd);
+        powerStationStatusDataRepository.save(p);
+        //对象转map
+        Map<String, String> map    = JSON.parseObject(JSON.toJSONString(p), new TypeReference<Map<String, String>>() {
+        });
+        redisUtils.hmset("power-" + electricField.getStationCode(), map);
+        log.info("实际功率结束");
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+
+  }
+  public void receiveQXZZT(Long endTime){
+    List<ElectricField> electricFieldList = electricFieldService.getAll();
+    log.info("开始调用通用接口请求气象站数据");
+    for (ElectricField electricField: electricFieldList){
+      List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.get(electricField.getStationCode());
+      if (!weatherStationInfoList.isEmpty()) {
+        for (WeatherStationInfo weatherStationInfo : weatherStationInfoList) {
+          getTaosDataMap(endTime, weatherStationInfo.getEquipmentNo(), weatherStationInfoList.get(0).getEquipmentType(), electricField.getStationCode());
+        }
+       }
+    }
+    log.info("调用通用接口请求气象站数据");
+  }
+  private void getTaosDataMap(Long endTime, String equipmentNo,EquipmentTypeEnum equipmentType,String stationCode) {
+    HashMap<String, Object> paramMap = new HashMap<>();
+    paramMap.put("deviceIds", equipmentNo);
+    paramMap.put("endTime", endTime);
+    paramMap.put("startTime",endTime-3000);
+    log.debug(JSON.toJSONString(paramMap));
+    String body = httpClientGetTaosData(paramMap);
+    log.debug(body);
+    AnalysisDataWeatherStationStatusData(body, equipmentType,stationCode);
+  }
+  /**
+   * 发http请求 通用接口 气象站
+   * @param paramMap 参数
+   * @return 返回的数据
+   */
+  public String httpClientGetTaosData( HashMap<String, Object> paramMap){
+    String body = "";
+    try{
+      CloseableHttpClient  httpClient = HttpClientBuilder.create().build();
+      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path+"getTaosData");
+
+      StringEntity entity = new StringEntity(JSON.toJSONString(paramMap),"UTF-8");
+      httpPost.setEntity(entity);
+      //设置请求超时时间,链接超时时间
+      RequestConfig reqConfig = RequestConfig.custom().setSocketTimeout(SOCKET_TIME_OUT).setConnectTimeout(CONNECT_TIME_OUT).build();
+      httpPost.setConfig(reqConfig);
+      httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
+      CloseableHttpResponse response;
+      response = httpClient.execute(httpPost);
+      HttpEntity responseEntity = response.getEntity();
+      body = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
+    }catch (RuntimeException | IOException e){
+      String errorInfo = "发送http请求气象站检修状态数据异常";
+      log.info(errorInfo);
+      log.info("所用线程"+Thread.currentThread().getName());
+      log.info("停止请求象站检修状态数据");
+      // 进行告警
+      String describe = "";
+      String solution = "停止请求象站检修状态数据";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, errorInfo, describe, errorInfo, solution);
+      Thread.currentThread().stop();
+    }
+    return body;
+  }
+
+  /**
+   * 气象站数据解析
+   * @param body http返回的数据
+   * @param equipmentType 设备类型
+   * @param stationCode 场站
+   */
+  public void AnalysisDataWeatherStationStatusData(String body, EquipmentTypeEnum equipmentType,String stationCode) {
+    try {
+      List<DataPoint> dataPointList = dataPointService.getByEquipmentType(equipmentType);
+      JSONObject jsonObject= JSON.parseObject(body);
+      JSONArray jsonResults = (JSONArray) jsonObject.get("results");
+      if (!jsonResults.isEmpty()){
+        for(int i = 0 ; i < jsonResults.size() ; i ++){
+          //results
+          JSONObject jsonObj = jsonResults.getJSONObject(i);
+          //设备id
+          String equipmentId  = (String) jsonObj.get("deviceId");
+          //rows
+          JSONArray jsonRows = (JSONArray) jsonObj.get("rows");
+          //所有设备点位
+          JSONArray sensorIds = (JSONArray) jsonObj.get("sensorIds");
+          JSONObject values;
+          Map<String, String> map = new HashMap<>();
+          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+          if (!jsonRows.isEmpty()){
+            values = jsonRows.getJSONObject(0);
+            //时间戳
+            String time = values.getString("timestamp");
+            //所有数据
+            JSONArray jsonValues = (JSONArray) values.get("values");
+            long timestamp = Long.parseLong(time);
+            //通过接收到的id找出编号
+            map.put("stationCode",stationCode);
+            map.put("equipmentId", equipmentId);
+            map.put("time", simpleDateFormat.format(timestamp));
+            for (DataPoint dataPoint : dataPointList) {
+              for (int j = 0; j < sensorIds.size(); j++) {
+                if (dataPoint.getMeasuringPoint().equals(sensorIds.get(j))) {
+                  if(jsonValues.get(j) == null ){
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), "-99");
+                  }else{
+                    map.put(dataPoint.getEquipmentAttribute().getFieldName(), jsonValues.get(j).toString());
+                  }
+                }
+              }
+            }
+            String STATUS = "status";
+            switch (map.get(STATUS)) {
+              case "1.00":
+              case "1.0":
+              case "true":
+                //运行
+                map.put(STATUS, "1");
+                break;
+              case "2.00":
+              case "2.0":
+                //待机
+                map.put(STATUS, "2");
+                break;
+              case "3.00":
+              case "3.0":
+                //停用
+                map.put(STATUS, "3");
+                break;
+              case "4.00":
+              case "4.0":
+              case "false":
+                //通讯中断
+                map.put(STATUS, "4");
+                break;
+              case "5.00":
+              case "5.0":
+              case "-99":
+                map.put(STATUS, "5");
+                break;
+              default:
+                break;
+            }
+            //气象站
+            redisUtils.hmset("qxz-" + stationCode + "-" + equipmentId, map);
+            WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
+            weatherStationStatusDataRepository.save(weatherStationStatusData);
+            log.info(map.get("time")+"qxz-" + stationCode + "-" + equipmentId+"已存入");
+          }else {
+            log.info("气象站" + "-" + equipmentId+"无数据,不进行任何操作");
+          }
+        }
+      }else {
+        log.info("对方没有气象站类型设备,请核对设备信息");
+      }
+    } catch (Exception e) {
+      log.info("气象站类型数据程序解析数据异常");
+      // 进行告警
+      String errorInfo = "气象站类型数据程序解析数据异常";
+      String name = "程序解析数据异常";
+      String describe = "";
+      String solution = "";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, name, describe, errorInfo, solution);
+      e.printStackTrace();
+    }
+  }
+}

+ 39 - 31
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveDataService.java

@@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.*;
 import com.jiayue.ipfcst.common.data.repository.*;
+import com.jiayue.ipfcst.common.data.service.BaseService;
 import com.jiayue.ipfcst.console.util.RedisUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.config.RequestConfig;
@@ -30,13 +32,13 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
- * 接收数据service类
+ * 接收数据service类 通用接口 单设备查询
  *
  * @author whc
  */
 @Service
 @Slf4j
-public class ReceiveDataService {
+public class ReceiveDataService extends BaseService {
   @Autowired
   ElectricFieldService electricFieldService;
   @Autowired
@@ -65,14 +67,17 @@ public class ReceiveDataService {
   PowerStationStatusDataRepository powerStationStatusDataRepository;
   @Autowired
   PowerStationDataPackerContainer powerStationDataPackerContainer;
-
+  @Autowired
+  SysAlarmService sysAlarmService;
   @Value("${receive.ip}")
   private String ip;
   @Value("${receive.port}")
-  private  String port;
+  private String port;
   @Value("${receive.path}")
-  private  String path;
-  private  final String Active = "activePower";
+  private String path;
+  @Value("${receive.mode}")
+  private String mode;
+  private final String Active = "activePower";
 
   //请求超时时间,这个时间定义了socket读数据的超时时间,也就是连接到服务器之后到从服务器获取响应数据需要等待的时间,发生超时,会抛出SocketTimeoutException异常。
   private static final int SOCKET_TIME_OUT = 5000;
@@ -80,13 +85,15 @@ public class ReceiveDataService {
   private static final int CONNECT_TIME_OUT = 3000;
 
 
+
   public void receive() {
     List<ElectricField> electricFieldList = electricFieldService.getAll();
+    long endTime =  DateTimeUtil.getCurrentTimeForMinute().getTime();
+    long startTime = endTime - 60000L;
     //每个场站请求一次
     for (ElectricField electricField : electricFieldList) {
       log.info(electricField.getName() + "开始请求数据");
-      Long startTime = DateTimeUtil.getCurrentTimeForMinute().getTime();
-      Long endTime = startTime + 60000L;
+
       try {
         //通用查询
         if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
@@ -125,8 +132,8 @@ public class ReceiveDataService {
     paramMap.put("deviceIds", equipmentNo);
     paramMap.put("startTime", startTime);
     paramMap.put("endTime", endTime);
-    log.info("param"+JSON.toJSONString(paramMap));
-    String body = httpClient(paramMap);
+    String body = httpClient(paramMap,electricField);
+    log.debug(body);
     AnalysisData(body, id, equipmentType, electricField);
   }
 
@@ -189,9 +196,10 @@ public class ReceiveDataService {
               break;
             case "4.00":
             case "false":
-              //故障
+              //通讯中断
               map.put(STATUS, "4");
               break;
+            case "5.00":
             case "-99":
               map.put(STATUS, "5");
               break;
@@ -206,7 +214,7 @@ public class ReceiveDataService {
               redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
               WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
               weatherStationStatusDataRepository.save(weatherStationStatusData);
-              log.info("qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+              log.info(map.get("time")+"qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
               break;
             case 2:
               //逆变器
@@ -222,7 +230,7 @@ public class ReceiveDataService {
               redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
               InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
               inverterStatusDataRepository.save(inverterStatusData);
-              log.info("nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+              log.info(map.get("time")+"nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
               break;
             case 3:
               redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
@@ -247,6 +255,12 @@ public class ReceiveDataService {
       }
     } catch (Exception e) {
       log.info(electricField.getName()+equipmentType.getMessage()+"接数程序异常");
+      // 进行告警
+      String errorInfo = electricField.getStationCode()+equipmentType.getMessage()+"接数程序异常";
+      String name = "接数程序异常";
+      String describe = "";
+      String solution = "";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, name, describe, errorInfo, solution,electricField.getStationCode());
       e.printStackTrace();
     }
   }
@@ -256,11 +270,11 @@ public class ReceiveDataService {
    * @param paramMap 参数
    * @return 返回的数据
    */
-  public String httpClient( HashMap<String, Object> paramMap){
+  public String httpClient( HashMap<String, Object> paramMap,ElectricField electricField){
     String body = "";
     try{
       CloseableHttpClient  httpClient = HttpClientBuilder.create().build();
-      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path);
+      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path+mode);
 
       StringEntity entity = new StringEntity(JSON.toJSONString(paramMap),"UTF-8");
       httpPost.setEntity(entity);
@@ -273,14 +287,22 @@ public class ReceiveDataService {
       HttpEntity responseEntity = response.getEntity();
       body = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
     }catch (RuntimeException | IOException e){
-      e.printStackTrace();
-      log.info("请求异常");
+      String errorInfo = "发送http请求数据异常";
+      log.info(errorInfo);
       log.info("所用线程"+Thread.currentThread().getName());
       log.info("停止请求数据");
+      // 进行告警
+      String describe = "";
+      String solution = "停止请求数据";
+      sysAlarmService.saveSysAlarm(AlarmTypeEnum.E5, errorInfo, describe, errorInfo, solution,electricField.getStationCode());
+
       Thread.currentThread().stop();
+
+
     }
     return body;
   }
+
   public void savePowerStationStatusData(ElectricField electricField) {
     try {
       log.info("开始计算实际功率");
@@ -318,18 +340,4 @@ public class ReceiveDataService {
       e.printStackTrace();
     }
   }
-  public  void stop(){
-    Thread thread = new Thread(() -> {
-      while (Thread.currentThread().isInterrupted()) {
-        log.info("停止请求数据");
-      }
-    });
-    thread.start();
-    try {
-      Thread.sleep(1);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    thread.interrupt();
-  }
 }

+ 44 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysAlarmService.java

@@ -1,8 +1,10 @@
 package com.jiayue.ipfcst.console.service;
 
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmStatusEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.SysAlarm;
 import com.jiayue.ipfcst.common.data.repository.SysAlarmRepository;
+import com.sun.istack.internal.NotNull;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
@@ -20,6 +22,48 @@ import java.util.List;
 public class SysAlarmService {
     private final SysAlarmRepository sysAlarmRepository;
 
+  /**
+   * 插入系统告警信息
+   *
+   * @param type      类型
+   * @param name      名称
+   * @param describe  描述
+   * @param errorInfo 错误日志
+   * @param solution  处理办法(插入的时候如果有处理建议,请给这个传值,比如(处理建议:联系运维人员处理))
+   * @param stationCode 所属场站
+   */
+  public void saveSysAlarm(@NotNull AlarmTypeEnum type,
+                           @NotNull String name, @NotNull String describe, String errorInfo, String solution,String stationCode) {
+    SysAlarm sysAlarm = new SysAlarm();
+    sysAlarm.setAlarmTypeEnum(type);
+    sysAlarm.setName(name);
+    sysAlarm.setDescribe(describe);
+    sysAlarm.setAlarmStatusEnum(AlarmStatusEnum.E1);
+    sysAlarm.setErrorInfo(errorInfo);
+    sysAlarm.setSolution(solution);
+    sysAlarm.setStationCode(stationCode);
+    sysAlarmRepository.save(sysAlarm);
+  }
+  /**
+   * 插入系统告警信息
+   *
+   * @param type      类型
+   * @param name      名称
+   * @param describe  描述
+   * @param errorInfo 错误日志
+   * @param solution  处理办法(插入的时候如果有处理建议,请给这个传值,比如(处理建议:联系运维人员处理))
+   */
+  public void saveSysAlarm(@NotNull AlarmTypeEnum type,
+                           @NotNull String name, @NotNull String describe, String errorInfo, String solution) {
+    SysAlarm sysAlarm = new SysAlarm();
+    sysAlarm.setAlarmTypeEnum(type);
+    sysAlarm.setName(name);
+    sysAlarm.setDescribe(describe);
+    sysAlarm.setAlarmStatusEnum(AlarmStatusEnum.E1);
+    sysAlarm.setErrorInfo(errorInfo);
+    sysAlarm.setSolution(solution);
+    sysAlarmRepository.save(sysAlarm);
+  }
     @Autowired
     public SysAlarmService(SysAlarmRepository sysAlarmRepository) {
         this.sysAlarmRepository = sysAlarmRepository;

+ 51 - 4
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -5,12 +5,14 @@ import com.alibaba.fastjson.JSON;
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
 import com.jiayue.ipfcst.common.data.abst.equipmentinfo.AbstractEquipmentInfo;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.*;
 import com.jiayue.ipfcst.common.data.repository.*;
 import com.jiayue.ipfcst.common.data.service.uploadfilerule.E63UploadFileRuleService;
 import com.jiayue.ipfcst.console.service.ForecastPowerShortTermService;
 import com.jiayue.ipfcst.console.service.ForecastPowerUltraShortTermService;
+import com.jiayue.ipfcst.console.service.SysAlarmService;
 import com.jiayue.ipfcst.console.util.RedisUtils;
 import com.jiayue.ipfcst.fileupload.util.FileUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -72,7 +74,9 @@ public class E63UploadFileService extends BaseUploadFileService {
 
   private final RedisUtils redisUtils;
 
-  public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService, WeatherStationInfoRepository weatherStationInfoRepository, WindTurbineInfoRepository windTurbineInfoRepository, WeatherStationStatusDataRepository weatherStationStatusDataRepository, WindTowerInfoRepository windTowerInfoRepository, WindTowerStatusDataRepository windTowerStatusDataRepository, NwpRepository nwpRepository, InverterInfoRepository inverterInfoRepository, WindTurbineStatusDataRepository windTurbineStatusDataRepository, InverterStatusDataRepository inverterStatusDataRepository, PowerStationStatusDataRepository powerStationStatusDataRepository, RedisUtils redisUtils) {
+  private final SysAlarmService sysAlarmService;
+
+  public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService, WeatherStationInfoRepository weatherStationInfoRepository, WindTurbineInfoRepository windTurbineInfoRepository, WeatherStationStatusDataRepository weatherStationStatusDataRepository, WindTowerInfoRepository windTowerInfoRepository, WindTowerStatusDataRepository windTowerStatusDataRepository, NwpRepository nwpRepository, InverterInfoRepository inverterInfoRepository, WindTurbineStatusDataRepository windTurbineStatusDataRepository, InverterStatusDataRepository inverterStatusDataRepository, PowerStationStatusDataRepository powerStationStatusDataRepository, RedisUtils redisUtils, SysAlarmService sysAlarmService) {
     this.velocityEngine = velocityEngine;
     this.forecastPowerShortTermService = forecastPowerShortTermService;
     this.forecastPowerUltraShortTermService = forecastPowerUltraShortTermService;
@@ -88,6 +92,7 @@ public class E63UploadFileService extends BaseUploadFileService {
     this.inverterStatusDataRepository = inverterStatusDataRepository;
     this.powerStationStatusDataRepository = powerStationStatusDataRepository;
     this.redisUtils = redisUtils;
+    this.sysAlarmService = sysAlarmService;
   }
 
   /**
@@ -166,6 +171,12 @@ public class E63UploadFileService extends BaseUploadFileService {
         }
       } catch (Exception e) {
         log.error(stationCode + "生成短期异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成短期预测上报文件异常";
+        String name = "生成短期文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -239,6 +250,12 @@ public class E63UploadFileService extends BaseUploadFileService {
         }
       } catch (Exception e) {
         log.error(stationCode + "生成可用短期异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成可用短期预测上报文件异常";
+        String name = "生成可用短期文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -319,6 +336,12 @@ public class E63UploadFileService extends BaseUploadFileService {
         }
       } catch (Exception e) {
         log.error(stationCode + "生成超短期异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成超短期预测上报文件异常";
+        String name = "生成超短期文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -401,6 +424,12 @@ public class E63UploadFileService extends BaseUploadFileService {
         }
       } catch (Exception e) {
         log.error(stationCode + "生成可用超短期异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成可用超短期预测上报文件异常";
+        String name = "生成可用超短期文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -445,7 +474,13 @@ public class E63UploadFileService extends BaseUploadFileService {
           }
         }
       } catch (Exception e) {
-        log.error(stationCode + "生成文件异常", e);
+        log.error(stationCode + "生成气象站或者测风塔文件异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成气象站或者测风塔文件异常";
+        String name = "生成气象站或者测风塔文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -889,7 +924,13 @@ public class E63UploadFileService extends BaseUploadFileService {
           }
         }
       } catch (Exception e) {
-        log.error(stationCode + "生成文件异常", e);
+        log.error(stationCode + "生成逆变器或风机文件异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成逆变器或风机文件异常";
+        String name = "生成逆变器或风机文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }
@@ -1316,7 +1357,13 @@ public class E63UploadFileService extends BaseUploadFileService {
           }
         }
       } catch (Exception e) {
-        log.error(stationCode + "生成文件异常", e);
+        log.error(stationCode + "生成理论功率文件异常", e);
+        // 进行告警
+        String errorInfo = stationCode+"生成理论功率上报文件异常";
+        String name = "生成理论功率文件异常";
+        String describe = "";
+        String solution = "";
+        sysAlarmService.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution,electricFieldInfo.getStationCode());
       }
     }
   }

+ 24 - 5
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/FtpUploadService.java

@@ -6,6 +6,7 @@ import cn.hutool.extra.ftp.Ftp;
 import cn.hutool.extra.ftp.FtpConfig;
 import cn.hutool.extra.ftp.FtpMode;
 import cn.hutool.extra.ssh.Sftp;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.ChannelStatusEnum;
 import com.jiayue.ipfcst.common.data.entity.UploadFileChannel;
 import com.jiayue.ipfcst.common.data.entity.UploadFileLog;
@@ -14,6 +15,7 @@ import com.jiayue.ipfcst.common.data.entity.UploadURL;
 import com.jiayue.ipfcst.common.data.repository.UploadFileLogDetailRepository;
 import com.jiayue.ipfcst.common.data.repository.UploadFileLogRepository;
 import com.jiayue.ipfcst.common.data.repository.UploadURLRepository;
+import com.jiayue.ipfcst.console.service.SysAlarmService;
 import com.jiayue.ipfcst.fileupload.config.AppenderFactory;
 import com.jiayue.ipfcst.fileupload.util.FileConstant;
 import lombok.extern.slf4j.Slf4j;
@@ -30,7 +32,7 @@ import java.util.stream.Collectors;
 
 @Service
 @Slf4j
-public class FtpUploadService {
+public class FtpUploadService{
   final
   UploadFileChannelService uploadFileChannelService;
   final
@@ -45,8 +47,10 @@ public class FtpUploadService {
   AppenderFactory appenderFactory;
   final
   UploadURLRepository uploadURLRepository;
+  final
+  SysAlarmService sysAlarmService;
 
-  public FtpUploadService(UploadFileChannelService uploadFileChannelService, UploadFileLogRepository uploadFileLogRepository, UploadFileLogDetailRepository uploadFileLogDetailRepository, UploadObjectService uploadObjectService, FtpUploadTransactionService ftpUploadTransactionService, AppenderFactory appenderFactory, UploadURLRepository uploadURLRepository) {
+  public FtpUploadService(UploadFileChannelService uploadFileChannelService, UploadFileLogRepository uploadFileLogRepository, UploadFileLogDetailRepository uploadFileLogDetailRepository, UploadObjectService uploadObjectService, FtpUploadTransactionService ftpUploadTransactionService, AppenderFactory appenderFactory, UploadURLRepository uploadURLRepository, SysAlarmService sysAlarmService) {
     this.uploadFileChannelService = uploadFileChannelService;
     this.uploadFileLogRepository = uploadFileLogRepository;
     this.uploadFileLogDetailRepository = uploadFileLogDetailRepository;
@@ -54,12 +58,13 @@ public class FtpUploadService {
     this.ftpUploadTransactionService = ftpUploadTransactionService;
     this.appenderFactory = appenderFactory;
     this.uploadURLRepository = uploadURLRepository;
+    this.sysAlarmService = sysAlarmService;
   }
 
   /**
    * 开启FTP客户端上报文件
    */
-  public void startFtpUpload() {
+  public void startFtpUpload(){
     List<UploadObject> uploadObjectList = uploadObjectService.get();
     // 过滤出ftp/sftp的上报对象
     uploadObjectList = uploadObjectList.stream().filter(s -> s.getUploadProtocolEnum().toString().equals("E4") || s.getUploadProtocolEnum().toString().equals("E5")).collect(Collectors.toList());
@@ -130,12 +135,19 @@ public class FtpUploadService {
                 while ((line = returnData.readLine()) != null) {
                   returnMsg.append(line);
                 }
-
+                String errorInfo = "";
                 if (returnMsg.indexOf("100% loss") != -1) {
                   logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接不畅通.");
+                  errorInfo = "与 " + uploadFileChannel.getRemoteIp() + " 连接不畅通.";
                 } else {
                   logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接畅通.");
+                  errorInfo = "与 " + uploadFileChannel.getRemoteIp() + " 连接畅通.";
                 }
+                // 进行告警
+                String name = "FTP上报文件异常";
+                String describe = "";
+                String solution = "";
+                sysAlarmService.saveSysAlarm(AlarmTypeEnum.E2, name, describe, errorInfo, solution,"");
 
                 returnData.close();
                 r.close();
@@ -190,13 +202,20 @@ public class FtpUploadService {
                 while ((line = returnData.readLine()) != null) {
                   returnMsg.append(line);
                 }
-
+                String errorInfo = "";
                 if (returnMsg.indexOf("100% loss") != -1) {
                   logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接不畅通.");
+                  errorInfo = "与 " + uploadFileChannel.getRemoteIp() + " 连接不畅通.";
                 } else {
                   logger.info("与 " + uploadFileChannel.getRemoteIp() + " 连接畅通.");
+                  errorInfo = "与 " + uploadFileChannel.getRemoteIp() + " 连接畅通.";
                 }
 
+                // 进行告警
+                String name = "SFTP上报文件异常";
+                String describe = "";
+                String solution = "";
+                sysAlarmService.saveSysAlarm(AlarmTypeEnum.E2, name, describe, errorInfo, solution,"");
                 returnData.close();
                 r.close();
                 process.getInputStream().close();

+ 2 - 2
ipfcst-console/src/main/resources/application.yml

@@ -122,5 +122,5 @@ fileupload:
 receive:
   ip: 10.220.57.13
   port: 7085
-  path: /dataService/v1/getTaosData
-
+  path: /dataService/v1/
+  mode: slice