Browse Source

程序移植

wanghc 3 years ago
parent
commit
f247b5fa00
19 changed files with 1714 additions and 30 deletions
  1. 66 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/HolidayCalendar.java
  2. 211 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/Nwp.java
  3. 219 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/NwpHis.java
  4. 0 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/SysParameter.java
  5. 20 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/FileAnalysisRecordRepository.java
  6. 14 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/HolidayCalendarRepository.java
  7. 39 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/NwpHisRepository.java
  8. 25 0
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/NwpRepository.java
  9. 1 0
      ipfcst-console/src/main/frontend/views/console/FileAnalysisRecord/index.vue
  10. 45 13
      ipfcst-console/src/main/frontend/views/console/sysParameter/index.vue
  11. 24 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/FileAnalysisRecordController.java
  12. 2 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/SysParameterController.java
  13. 46 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/DownLoadServiceJob.java
  14. 38 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/FileAnalysisJob.java
  15. 32 14
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DownLoadService.java
  16. 30 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/FileAnalysisRecordService.java
  17. 587 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/FileAnalysisService.java
  18. 121 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/HolidayCalendarService.java
  19. 194 0
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java

+ 66 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/HolidayCalendar.java

@@ -0,0 +1,66 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import com.jiayue.ipfcst.common.data.abst.AbstractBaseEntity;
+import com.jiayue.ipfcst.common.data.constant.enums.HolidayTypeEnum;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.*;
+
+/**
+ * 假期日历实体
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/7/22 11:16
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Entity
+public class HolidayCalendar extends AbstractBaseEntity {
+
+    /**
+     * 假日编号
+     */
+    @GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
+    @GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
+    @Id
+    @Column
+    private Integer id;
+
+    /**
+     * 假日名称
+     */
+    @Column
+    private String name;
+
+    /**
+     * 假日开始时间
+     */
+    @Column
+    private Long startTime;
+
+    /**
+     * 假日结束时间
+     */
+    @Column
+    private Long endTime;
+
+    /**
+     * 假日天数
+     */
+    @Column
+    private Integer days;
+
+    /**
+     * 假期类型
+     */
+    @Column
+    @Enumerated(EnumType.STRING)
+    private HolidayTypeEnum holidayTypeEnum;
+
+    @Column
+    private String stationCode;
+
+}

+ 211 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/Nwp.java

@@ -0,0 +1,211 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import lombok.Data;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.core.annotation.Order;
+
+import javax.persistence.*;
+import javax.validation.constraints.Digits;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 数值天气预报实时数据
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2018/10/23 9:16
+ */
+@Entity
+@Data
+public class Nwp implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Order(1)
+    @GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
+    @GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
+    private Integer id;
+
+    /**
+     * 预测时间
+     */
+    @Column
+    private Long preTime;
+
+    /**
+     * 场站ID
+     */
+    @Column
+    private String farmId;
+    /**
+     * 生成日期
+     */
+    @Column
+    private String scDate;
+    /**
+     * 生成时间
+     */
+    @Column
+    private String scTime;
+    /**
+     * 预测日期
+     */
+    @Column
+    private String preDate;
+
+    /**
+     * 温度
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal t = new BigDecimal(-99);
+    /**
+     * 湿度
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal rh = new BigDecimal(-99);
+    /**
+     * 气压
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal pressure = new BigDecimal(-99);
+    /**
+     * 短波辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal swr = new BigDecimal(-99);
+
+    /**
+     * 短波辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal lwr = new BigDecimal(-99);
+    /**
+     * 直辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal directRadiation = new BigDecimal(-99);
+    /**
+     * 散辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal diffuseRadiation = new BigDecimal(-99);
+    /**
+     * 热感通量
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal senf = new BigDecimal(-99);
+
+
+    /**
+     * 10米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws10 = new BigDecimal(-99);
+    /**
+     * 30米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws30 = new BigDecimal(-99);
+    /**
+     * 50米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws50 = new BigDecimal(-99);
+    /**
+     * 70米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws70 = new BigDecimal(-99);
+    /**
+     * 80米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws80 = new BigDecimal(-99);
+    /**
+     * 90米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws90 = new BigDecimal(-99);
+    /**
+     * 100米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws100 = new BigDecimal(-99);
+    /**
+     * 170米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws170 = new BigDecimal(-99);
+    /**
+     * 10米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd10 = new BigDecimal(-99);
+    /**
+     * 30米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd30 = new BigDecimal(-99);
+    /**
+     * 50米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd50 = new BigDecimal(-99);
+    /**
+     * 70米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd70 = new BigDecimal(-99);
+    /**
+     * 80米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd80 = new BigDecimal(-99);
+    /**
+     * 90米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd90 = new BigDecimal(-99);
+    /**
+     * 100米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd100 = new BigDecimal(-99);
+    /**
+     * 170米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd170 = new BigDecimal(-99);
+
+    /**
+     * 场站标识
+     */
+    @Column
+    private String stationCode;
+}

+ 219 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/NwpHis.java

@@ -0,0 +1,219 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+import lombok.Data;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.core.annotation.Order;
+import org.springframework.data.annotation.CreatedDate;
+
+import javax.persistence.*;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 数值天气预报历史数据
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/11/28 16:05
+ */
+@Data
+@Entity
+public class NwpHis {
+    @Id
+    @Order(1)
+    @GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
+    @GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
+    private Integer id;
+
+    /*提前多久预测*/
+    @Column
+    private Integer forecastHowLongAgo;
+    /**
+     * 历史数据产生时间
+     */
+    @Order(100)
+    @Temporal(TemporalType.TIMESTAMP)
+    @CreatedDate
+    @Column
+    private Date genDate;
+
+    /**
+     * 预测时间
+     */
+    @Column
+    private Long preTime;
+
+    /**
+     * 场站ID
+     */
+    @Column
+    private String farmId;
+    /**
+     * 生成日期
+     */
+    @Column
+    private String scDate;
+    /**
+     * 生成时间
+     */
+    @Column
+    private String scTime;
+    /**
+     * 预测日期
+     */
+    @Column
+    private String preDate;
+
+    /**
+     * 温度
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal t = new BigDecimal(-99);
+    /**
+     * 湿度
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal rh = new BigDecimal(-99);
+    /**
+     * 气压
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal pressure = new BigDecimal(-99);
+    /**
+     * 辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal swr = new BigDecimal(-99);
+
+    /**
+     * 短波辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal lwr = new BigDecimal(-99);
+    /**
+     * 直辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal directRadiation = new BigDecimal(-99);
+    /**
+     * 散辐射
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal diffuseRadiation = new BigDecimal(-99);
+    /**
+     * 热感通量
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal senf = new BigDecimal(-99);
+    /**
+     * 10米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws10 = new BigDecimal(-99);
+    /**
+     * 30米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws30 = new BigDecimal(-99);
+    /**
+     * 50米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws50 = new BigDecimal(-99);
+    /**
+     * 70米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws70 = new BigDecimal(-99);
+    /**
+     * 80米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws80 = new BigDecimal(-99);
+    /**
+     * 90米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws90 = new BigDecimal(-99);
+    /**
+     * 100米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws100 = new BigDecimal(-99);
+    /**
+     * 170米风速
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal ws170 = new BigDecimal(-99);
+    /**
+     * 10米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd10 = new BigDecimal(-99);
+    /**
+     * 30米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd30 = new BigDecimal(-99);
+    /**
+     * 50米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd50 = new BigDecimal(-99);
+    /**
+     * 70米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd70 = new BigDecimal(-99);
+    /**
+     * 80米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd80 = new BigDecimal(-99);
+    /**
+     * 90米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd90 = new BigDecimal(-99);
+    /**
+     * 100米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd100 = new BigDecimal(-99);
+    /**
+     * 170米风向
+     */
+    @Column
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal wd170 = new BigDecimal(-99);
+
+    /**
+     * 场站标识
+     */
+    @Column
+    private String stationCode;
+}

+ 0 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/SysParameter.java

@@ -29,7 +29,6 @@ public class SysParameter extends AbstractBaseEntity {
     /**
     /**
      * 参数标识
      * 参数标识
      */
      */
-    @Column(unique = true)
     private String sysKey;
     private String sysKey;
 
 
     /**
     /**

+ 20 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/FileAnalysisRecordRepository.java

@@ -0,0 +1,20 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+import com.jiayue.ipfcst.common.data.entity.FileAnalysisRecord;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 文件解析仓储
+ */
+public interface FileAnalysisRecordRepository
+		extends BaseRepository<FileAnalysisRecord, Integer> {
+	/**
+	 * 按时间段查询数据
+	 *
+	 * @param startTime
+	 * @param endTime
+	 */
+	List<FileAnalysisRecord> findByCreateTimeBetween(Date startTime, Date endTime);
+}

+ 14 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/HolidayCalendarRepository.java

@@ -0,0 +1,14 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+
+import com.jiayue.ipfcst.common.data.entity.HolidayCalendar;
+
+/**
+ * 假期日历仓储
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/7 15:47
+ */
+public interface HolidayCalendarRepository extends BaseRepository<HolidayCalendar, Integer> {
+}

+ 39 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/NwpHisRepository.java

@@ -0,0 +1,39 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+import com.jiayue.ipfcst.common.data.entity.Nwp;
+import com.jiayue.ipfcst.common.data.entity.NwpHis;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+/**
+ * nwp数据仓储
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/9/26 11:23
+ */
+public interface NwpHisRepository extends BaseRepository<NwpHis, Integer> {
+
+	/**
+	 * 根据时间段删除当日凌晨零点以后生成的NWP史期数据
+	 *
+	 * @param startTime 开始时间
+	 * @param endTime   结束时间
+	 */
+	@Modifying
+	@Query(value = "delete from NwpHis t where t.genDate >= CURRENT_DATE and t.preTime >=?1 and t.preTime<=?2")
+	void deleteToday(Long startTime, Long endTime);
+
+	/**
+	 * 按时间段查询数据
+	 *
+	 * @param startTime
+	 * @param endTime
+	 */
+	List<Nwp> findByPreTimeBetween(Long startTime, Long endTime);
+
+
+	List<NwpHis> findByPreTimeBetweenAndForecastHowLongAgo(Long startTime,Long endTIme,Integer ago);
+}

+ 25 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/NwpRepository.java

@@ -0,0 +1,25 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+import com.jiayue.ipfcst.common.data.entity.Nwp;
+
+import java.util.List;
+
+/**
+ * nwp数据仓储
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/9/26 11:23
+ */
+public interface NwpRepository extends BaseRepository<Nwp, Integer> {
+
+	void deleteByPreTimeBetweenAndStationCode(Long startTime, Long endTime,String stationCode);
+
+	/**
+	 * 按时间段查询数据
+	 *
+	 * @param startTime
+	 * @param endTime
+	 */
+	List<Nwp> findByPreTimeBetween(Long startTime, Long endTime);
+}

+ 1 - 0
ipfcst-console/src/main/frontend/views/console/FileAnalysisRecord/index.vue

@@ -33,6 +33,7 @@
         >
         >
         <vxe-table-column title="文件解析记录">
         <vxe-table-column title="文件解析记录">
 <!--          <vxe-table-column field="createTime" title="时间" :formatter="timestampToTimess"></vxe-table-column>-->
 <!--          <vxe-table-column field="createTime" title="时间" :formatter="timestampToTimess"></vxe-table-column>-->
+          <vxe-table-column field="stationCode" title="所属场站"></vxe-table-column>
           <vxe-table-column field="fileTitle" title="文件名称"></vxe-table-column>
           <vxe-table-column field="fileTitle" title="文件名称"></vxe-table-column>
           <vxe-table-column field="fileType" title="文件类型"></vxe-table-column>
           <vxe-table-column field="fileType" title="文件类型"></vxe-table-column>
           <vxe-table-column field="fileDescription" title="文件描述"></vxe-table-column>
           <vxe-table-column field="fileDescription" title="文件描述"></vxe-table-column>

+ 45 - 13
ipfcst-console/src/main/frontend/views/console/sysParameter/index.vue

@@ -11,6 +11,14 @@
         >导出数据
         >导出数据
         </el-button>
         </el-button>
       </div>
       </div>
+      <el-select v-model="codeData" :filterable="true" placeholder="选择场站">
+        <el-option
+          v-for="item in this.eCode"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value"
+          @click.native="getDataByEl"/>
+      </el-select>
       <el-button
       <el-button
         type="primary"
         type="primary"
         size="small"
         size="small"
@@ -53,9 +61,15 @@
         >
         >
           <vxe-table-column title="参数配置">
           <vxe-table-column title="参数配置">
             <vxe-table-column
             <vxe-table-column
+              field="stationCode"
+              title="所属场站"
+              width="10%"
+              :edit-render="{name: '$input', props: {type: 'text', readonly: !add}}"
+            />
+            <vxe-table-column
               field="sysKey"
               field="sysKey"
               title="参数"
               title="参数"
-              width="25%"
+              width="20%"
               :edit-render="{name: '$input', props: {type: 'text', readonly: !add}}"
               :edit-render="{name: '$input', props: {type: 'text', readonly: !add}}"
             />
             />
             <vxe-table-column
             <vxe-table-column
@@ -66,7 +80,7 @@
             <vxe-table-column
             <vxe-table-column
               field="describe"
               field="describe"
               title="参数描述"
               title="参数描述"
-              width="30%"
+              width="25%"
               :edit-render="{name: '$input', attrs: {type: 'text'}}"
               :edit-render="{name: '$input', attrs: {type: 'text'}}"
             />
             />
             <vxe-table-column field="creator" title="创建人" width="8%" />
             <vxe-table-column field="creator" title="创建人" width="8%" />
@@ -145,7 +159,12 @@ export default {
       currentPage: 1,
       currentPage: 1,
       pageSize: 10,
       pageSize: 10,
       total: 0,
       total: 0,
+      eCode:[],
+      codeData:'',
       rules: {
       rules: {
+        stationCode: [
+          { required: true, message: '所属场站不能为空' }
+        ],
         sysKey: [
         sysKey: [
           { required: true, message: '参数标识不能为空' }
           { required: true, message: '参数标识不能为空' }
         ],
         ],
@@ -160,8 +179,31 @@ export default {
   },
   },
   created() {
   created() {
     this.getAll()
     this.getAll()
+    this.getEl()
   },
   },
   methods: {
   methods: {
+    getDataByEl(){
+      this.loading = true
+      this.saveLoding = false
+      this.$axios.get('/sysParameter/'+this.codeData).then((res) => {
+        this.tableData = res.data
+        this.loading = false
+      }).catch((error) => {
+        this.$message.error('获取系统参数信息出错' + error)
+      })
+    },
+    getEl() {
+      this.loading = true
+      this.saveLoding = false
+      this.$axios.get('/electricField/getElectricField').then((res) => {
+      for(let i = 0 ; i < res.data.length ; i ++){
+        console.log(res.data[i].name)
+        this.eCode.push({label:res.data[i].stationCode.toString()+res.data[i].name,value:res.data[i].stationCode})
+      }
+      }).catch((error) => {
+        this.$message.error('获取系统参数信息出错' + error)
+      })
+    },
     activeCellMethod({ column, columnIndex }) {
     activeCellMethod({ column, columnIndex }) {
       if (columnIndex === 1) {
       if (columnIndex === 1) {
         return false
         return false
@@ -259,17 +301,7 @@ export default {
         })
         })
       }
       }
     },
     },
-    // removeEvent(row) {
-    //   window.console.log(row)
-    //   this.$XModal.confirm('您确定要删除该数据?').then(type => {
-    //     if (type === 'confirm') {
-    //       this.$axios.delete('/sysParameter/',{data:row}).then(response => {
-    //         this.$XModal.message({status: 'warning', message: response.message})
-    //         this.$refs.xTable.remove(row)
-    //       })
-    //     }
-    //   })
-    // },
+
     dateFormat(row, column) {
     dateFormat(row, column) {
       var date = row.cellValue
       var date = row.cellValue
 
 

+ 24 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/FileAnalysisRecordController.java

@@ -0,0 +1,24 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.FileAnalysisRecord;
+import com.jiayue.ipfcst.console.service.FileAnalysisRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.List;
+
+@RestController
+public class FileAnalysisRecordController {
+  @Autowired
+  FileAnalysisRecordService fileAnalysisRecordService;
+
+  @GetMapping("/FileAnalysisRecord/{startTime}")
+  public ResponseVO findByCreateTimeBetween(@PathVariable Long startTime) {
+    List<FileAnalysisRecord> fileAnalysisRecords = fileAnalysisRecordService.findByCreateTimeBetween(new Date(startTime), new Date(startTime + 86400000l));
+    return ResponseVO.success(fileAnalysisRecords);
+  }
+}

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

@@ -81,12 +81,12 @@ public class SysParameterController {
 
 
 
 
     /**
     /**
-     * 获取所有系统参数
+     * 获取该场站下的所有参数
      *
      *
      * @return 执行结果
      * @return 执行结果
      */
      */
     @SneakyThrows
     @SneakyThrows
-    @GetMapping(value = "/sysParameter/{stationCode}/")
+    @GetMapping(value = "/{stationCode}")
     public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
     public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
       List<SysParameter> list = this.sysParameterService.getAllByStationCode(stationCode);
       List<SysParameter> list = this.sysParameterService.getAllByStationCode(stationCode);
       return ResponseVO.success(list);
       return ResponseVO.success(list);

+ 46 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/DownLoadServiceJob.java

@@ -0,0 +1,46 @@
+package com.jiayue.ipfcst.console.job;
+
+import com.jiayue.ipfcst.common.data.entity.ElectricField;
+import com.jiayue.ipfcst.console.service.DownLoadService;
+import com.jiayue.ipfcst.console.service.ElectricFieldService;
+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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 天气预报下载
+ *
+ * @author whc
+ * @version 3.0
+ */
+@Slf4j
+@Service
+@EnableScheduling
+public class DownLoadServiceJob {
+
+    @Autowired
+    private DownLoadService downLoadService;
+
+    @Autowired
+    private ElectricFieldService electricFieldService;
+    @Scheduled(cron = "0 0/15 * * * *")
+    public void fxglFileAnalysis() {
+
+        log.debug("天气预报文件下载定时任务开始执行");
+
+        List<ElectricField> electricFieldList = electricFieldService.getAll();
+        for(ElectricField electricField : electricFieldList){
+          this.downLoadService.download(electricField.getStationCode());
+        }
+
+        log.debug("天气预报文件下载定时任务执行结束");
+
+    }
+
+
+}

+ 38 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/FileAnalysisJob.java

@@ -0,0 +1,38 @@
+package com.jiayue.ipfcst.console.job;
+
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.data.entity.ElectricField;
+import com.jiayue.ipfcst.console.service.FileAnalysisService;
+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;
+
+/**
+ * 文件解析
+ *
+ * @author bizy
+ * @version 3.0
+ */
+@Slf4j
+@Service
+@EnableScheduling
+public class FileAnalysisJob {
+
+    @Autowired
+    private FileAnalysisService fileAnalysisService;
+
+    @Scheduled(cron = "0 0/1 * * * *")
+    public void fxglFileAnalysis() {
+
+        log.debug("文件解析定时任务执行开始");
+
+        this.fileAnalysisService.analysisJob();
+
+        log.debug("文件解析定时任务执行完成");
+
+    }
+
+
+}

+ 32 - 14
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DownLoadService.java

@@ -8,11 +8,14 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipfcst.common.data.entity.FileCreateLog;
 import com.jiayue.ipfcst.common.data.entity.FileCreateLog;
+import com.jiayue.ipfcst.fileupload.util.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
 
 
 import java.io.File;
 import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -27,34 +30,38 @@ import java.util.List;
 public class DownLoadService {
 public class DownLoadService {
 
 
 	public void download(String stationCode) {
 	public void download(String stationCode) {
-    //@Valid注解启动后台校验,
-    ModelAndView modelAndView = new ModelAndView();
-    Long startT = System.currentTimeMillis();
-    log.info("下载RB文件开始,时间:" + DateTimeUtil.getStringDate());
-
-    String message = "下载成功!";
     log.info("开始执行定时任务:http下载文件");
     log.info("开始执行定时任务:http下载文件");
-    String body = HttpRequest.get("https://117.78.19.70:9010/client/getDownLoadFileAll/" + "T00003").execute().body();
+    String body = HttpRequest.get("https://117.78.19.70:9010/client/getDownLoadFileAll/" + stationCode).execute().body();
     JSONObject json = JSONUtil.parseObj(body);
     JSONObject json = JSONUtil.parseObj(body);
     String code = json.get("code").toString();
     String code = json.get("code").toString();
     String data = json.get("data").toString();
     String data = json.get("data").toString();
     if (code.equals("0") && data.length() > 0) {
     if (code.equals("0") && data.length() > 0) {
       JSONArray array = JSONUtil.parseArray(data);
       JSONArray array = JSONUtil.parseArray(data);
       List<FileCreateLog> list = array.toList(FileCreateLog.class);
       List<FileCreateLog> list = array.toList(FileCreateLog.class);
-      String dir = "/Users/wanghongchen/fsdownload/"+"T00003";
+      Date date = new Date();
+      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+      //String dir = FileUtil.getDownloadFilePath() +File.separator+stationCode+File.separator+"new/";
+      //String dirBak = FileUtil.getDownloadFilePath() +File.separator+stationCode+File.separator+"backups/"+simpleDateFormat.format(date)+"/";
+      //测试使用
+      String dir = "/Users/wanghongchen/fsdownload/"+stationCode+"/"+"new/";
+      String dirBak = "/Users/wanghongchen/fsdownload/"+stationCode+"/"+"backups/"+simpleDateFormat.format(date)+"/";
       //循环backups下的文件,有文件则不下载
       //循环backups下的文件,有文件则不下载
       File fileDirectory = new File(dir);
       File fileDirectory = new File(dir);
       if(!fileDirectory.exists()){
       if(!fileDirectory.exists()){
         fileDirectory.mkdir();
         fileDirectory.mkdir();
       }
       }
+      File bakDirectory = new File(dirBak);
+      if(!bakDirectory.exists()){
+        bakDirectory.mkdir();
+      }
       try {
       try {
         for (FileCreateLog fileCreateLog : list) {
         for (FileCreateLog fileCreateLog : list) {
-          File file= new File(fileDirectory+File.separator+fileCreateLog.getFileName());
+          File file= new File(bakDirectory+File.separator+fileCreateLog.getFileName());
           if(!file.exists()){
           if(!file.exists()){
             String url = "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
             String url = "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
             long a = HttpUtil.downloadFile(url, dir + File.separatorChar + fileCreateLog.getFileName());
             long a = HttpUtil.downloadFile(url, dir + File.separatorChar + fileCreateLog.getFileName());
             if(a>0){
             if(a>0){
-              log.info("T00003"+"场站"+fileCreateLog.getFileName()+"文件下载成功");
+              log.info(stationCode+"场站"+fileCreateLog.getFileName()+"文件下载成功");
             }
             }
           }else{
           }else{
             log.info("文件已经下载过了");
             log.info("文件已经下载过了");
@@ -66,6 +73,10 @@ public class DownLoadService {
     }
     }
 	}
 	}
 
 
+  public void downloadJob() {
+
+  }
+
   public static void main(String[] args) {
   public static void main(String[] args) {
     //@Valid注解启动后台校验,
     //@Valid注解启动后台校验,
     ModelAndView modelAndView = new ModelAndView();
     ModelAndView modelAndView = new ModelAndView();
@@ -74,27 +85,34 @@ public class DownLoadService {
 
 
     String message = "下载成功!";
     String message = "下载成功!";
     log.info("开始执行定时任务:http下载文件");
     log.info("开始执行定时任务:http下载文件");
-    String body = HttpRequest.get("https://117.78.19.70:9010/client/getDownLoadFileAll/" + "T00004").execute().body();
+    String body = HttpRequest.get("https://117.78.19.70:9010/client/getDownLoadFileAll/" + "J00059").execute().body();
     JSONObject json = JSONUtil.parseObj(body);
     JSONObject json = JSONUtil.parseObj(body);
     String code = json.get("code").toString();
     String code = json.get("code").toString();
     String data = json.get("data").toString();
     String data = json.get("data").toString();
     if (code.equals("0") && data.length() > 0) {
     if (code.equals("0") && data.length() > 0) {
       JSONArray array = JSONUtil.parseArray(data);
       JSONArray array = JSONUtil.parseArray(data);
       List<FileCreateLog> list = array.toList(FileCreateLog.class);
       List<FileCreateLog> list = array.toList(FileCreateLog.class);
-      String dir = "/Users/wanghongchen/fsdownload/"+"T00004";
+      Date date = new Date();
+      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+      String dir = "/Users/wanghongchen/fsdownload/"+"J00059"+"/"+"new/";
+      String dirBak = "/Users/wanghongchen/fsdownload/"+"J00059"+"/"+"backups/"+simpleDateFormat.format(date)+"/";
       //循环backups下的文件,有文件则不下载
       //循环backups下的文件,有文件则不下载
       File fileDirectory = new File(dir);
       File fileDirectory = new File(dir);
       if(!fileDirectory.exists()){
       if(!fileDirectory.exists()){
         fileDirectory.mkdir();
         fileDirectory.mkdir();
       }
       }
+      File bakDirectory = new File(dirBak);
+      if(!bakDirectory.exists()){
+        bakDirectory.mkdir();
+      }
       try {
       try {
         for (FileCreateLog fileCreateLog : list) {
         for (FileCreateLog fileCreateLog : list) {
-          File file= new File(fileDirectory+File.separator+fileCreateLog.getFileName());
+          File file= new File(bakDirectory+File.separator+fileCreateLog.getFileName());
           if(!file.exists()){
           if(!file.exists()){
             String url = "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
             String url = "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
             long a = HttpUtil.downloadFile(url, dir + File.separatorChar + fileCreateLog.getFileName());
             long a = HttpUtil.downloadFile(url, dir + File.separatorChar + fileCreateLog.getFileName());
             if(a>0){
             if(a>0){
-              log.info("T00004"+"场站"+fileCreateLog.getFileName()+"文件下载成功");
+              log.info("J00059"+"场站"+fileCreateLog.getFileName()+"文件下载成功");
             }
             }
           }else{
           }else{
             log.info("文件已经下载过了");
             log.info("文件已经下载过了");

+ 30 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/FileAnalysisRecordService.java

@@ -0,0 +1,30 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.jiayue.ipfcst.common.data.entity.FileAnalysisRecord;
+import com.jiayue.ipfcst.common.data.repository.FileAnalysisRecordRepository;
+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 java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class FileAnalysisRecordService extends BaseService {
+    @Autowired
+    FileAnalysisRecordRepository fileAnalysisRecordRepository;
+
+    public void save(FileAnalysisRecord fileAnalysisRecord) {
+        fileAnalysisRecordRepository.save(fileAnalysisRecord);
+    }
+
+
+    public List<FileAnalysisRecord> findByCreateTimeBetween(Date startTime, Date endTime){
+      return fileAnalysisRecordRepository.findByCreateTimeBetween(startTime,endTime).stream().sorted(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed()).collect(Collectors.toList());
+
+    }
+}

+ 587 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/FileAnalysisService.java

@@ -0,0 +1,587 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.core.util.NumberUtils;
+import com.jiayue.ipfcst.common.data.constant.enums.HolidayTypeEnum;
+import com.jiayue.ipfcst.common.data.constant.enums.PredictionModelEnum;
+import com.jiayue.ipfcst.common.data.entity.*;
+import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
+import com.jiayue.ipfcst.common.data.repository.HolidayCalendarRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import com.jiayue.ipfcst.fileupload.util.FileUtil;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.springframework.stereotype.Service;
+
+import java.io.*;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 解析电科院NWP和DQ文件
+ *
+ * @author cuil
+ * @version 2.0
+ * @since 2018/12/03 11:24
+ */
+
+@AllArgsConstructor
+@Service
+@Slf4j
+public class FileAnalysisService extends BaseService {
+
+	ElectricFieldService electricFieldService;
+
+	ForecastPowerShortTermService forecastPowerShortTermService;
+
+	HolidayCalendarRepository holidayCalendarRepository;
+
+	NwpService nwpService;
+
+	FileAnalysisRecordService fileAnalysisRecordService;
+
+	OverHaulPlanService overHaulPlanService;
+
+	SysParameterService sysParameterService;
+
+	ElectricFieldRepository electricFieldRepository;
+
+	HolidayCalendarService holidayCalendarService;
+
+
+
+	@SneakyThrows
+	public void analysisJob() {
+		log.info("-----------------开始执行文件解析任务----------------------");
+		long timeD = 15 * 60 * 1000;
+		Long currentDate = DateTimeUtil.getMillisecondsSubDay();//今日凌晨
+		boolean flag = false;
+		List<ElectricField> electricFieldList = electricFieldService.getAll();
+    List<String> eList = new ArrayList<>();
+    for(ElectricField electricField : electricFieldList){
+      eList.add(electricField.getStationCode());
+    }
+		//String path = FileUtil.getDownloadFilePath() + File.separator + "new";
+    String path = FileUtil.getDownloadFilePath();
+    //downloadFile
+		File dirFile = new File(path);
+		//判断该目录是否存在,不存在时创建
+		if (!dirFile.exists()) {
+			dirFile.mkdirs();
+		}
+		log.info("系统扫描路径【" + dirFile.getPath() + "】");
+    for(String stationCode : eList){
+      // downLoadFile/场站编号/new
+      //String dirFiles = dirFile.getPath()+File.separator+ stationCode+ File.separator + "new";
+      String dirFiles = "/Users/wanghongchen/fsdownload"+File.separator+ stationCode+ File.separator + "new";
+      File  filePath = new File(dirFiles);
+      if (!filePath.exists()) {
+        filePath.mkdirs();
+      }
+      Collection<File> files = FileUtils.listFiles(filePath, new String[]{"RB"}, false);
+      String dayStr = new SimpleDateFormat("yyyyMMdd").format(new Date());//当前时间格式化为年月日
+      if (files != null && files.size() > 0) {
+        for (File file : files) {
+          flag = false;
+          boolean sfqbxf = false;
+          boolean startConsole = false;
+          String fileName = file.getName();
+          if (fileName.indexOf(dayStr) < 0) {
+            file.delete();
+            log.info(fileName + "不是当天的文件,删除!");
+            break;
+          }
+          if (fileName.length() < 30) {
+            //假期文件
+            if (file.getName().startsWith("JH")) {
+              List<HolidayCalendar> listJq = fileAnalysisJqTerm(file);
+              if (listJq != null && listJq.size() > 0) {
+                holidayCalendarRepository.deleteAll();
+                holidayCalendarRepository.saveAll(listJq);
+                flag = true;
+              } else {
+                flag = false;
+              }
+            }
+            if (file.getName().startsWith("DQ")) {
+              try {
+                List<ForecastPowerShortTerm> listDq = fileAnalysisShortTerm(file, currentDate,stationCode);
+                ForecastPowerShortTerm forecastPowerShortTerm = null;
+                if (listDq != null && listDq.size() > 0) {
+                  //如果数据不全,进行补入
+                  while (listDq.get(listDq.size() - 1).getForecastTime() < DateTimeUtil.getMillisecondsSubDay() + 4 * 24 * 60 * 60 * 1000 - timeD) {
+                    forecastPowerShortTerm = new ForecastPowerShortTerm();
+                    forecastPowerShortTerm.setFpValue(listDq.get(listDq.size() - 96).getFpValue());//修正前值
+                    forecastPowerShortTerm.setGenDate(new Date()); //装机容量
+                    forecastPowerShortTerm.setForecastTime(currentDate);
+                    forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E1);
+                    forecastPowerShortTerm.setStationCode(stationCode);
+                    listDq.add(forecastPowerShortTerm);
+                  }
+                  try {
+                    //短期数据修正
+                    Long startTime = listDq.get(0).getForecastTime();
+                    Long endTime = listDq.get(listDq.size() - 1).getForecastTime();//删除相同时间数据
+                    forecastPowerShortTermService.deleteBetweenAndGenTime(startTime, endTime, listDq,stationCode);
+                    flag = true;
+                  } catch (Exception e) {
+                    log.error("保存短期数据报错", e);
+                    flag = false;
+                  }
+                } else {
+                  log.info(file.getName() + "文件数据内容为空、不能正常解析 、移除该文件、执行数据修正功能");
+                  flag = false;
+                }
+              } catch (Exception e) {
+                flag = false;
+                log.error("解析DQ文件失败", e);
+              }
+            }
+            if (file.getName().startsWith("NWP")) {
+              try {
+                List<Nwp> listNwp = fileAnalysisNwp(file,stationCode);
+                Nwp nwpData = null;
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                if (listNwp != null && listNwp.size() > 0) {
+                  while (listNwp.get(listNwp.size() - 1).getPreTime() < DateTimeUtil.getMillisecondsSubDay() + 4 * 24 * 60 * 60 * 1000 - timeD) {
+                    nwpData = new Nwp();
+                    long time = 0;
+                    try {
+                      time = sdf.parse(listNwp.get(listNwp.size() - 96).getPreDate()).getTime() + 24 * 60 * 60 * 1000;
+                    } catch (ParseException e) {
+                      e.printStackTrace();
+                    }
+                    nwpData.setFarmId(listNwp.get(listNwp.size() - 96).getFarmId());
+                    nwpData.setScDate(listNwp.get(listNwp.size() - 96).getScDate());
+                    nwpData.setScTime(listNwp.get(listNwp.size() - 96).getScTime());
+                    nwpData.setPreDate(sdf.format(time));
+                    nwpData.setPreTime(listNwp.get(listNwp.size() - 1).getPreTime() + timeD);
+                    nwpData.setT(listNwp.get(listNwp.size() - 96).getT());//温度
+                    nwpData.setRh(listNwp.get(listNwp.size() - 96).getRh());//湿度
+                    nwpData.setPressure(listNwp.get(listNwp.size() - 96).getPressure());//气压
+                    nwpData.setSwr(listNwp.get(listNwp.size() - 96).getSwr());//辐射
+                    nwpData.setLwr(listNwp.get(listNwp.size() - 96).getLwr());//辐射
+                    nwpData.setDiffuseRadiation(listNwp.get(listNwp.size() - 96).getDiffuseRadiation());//散接辐射
+                    nwpData.setDirectRadiation(listNwp.get(listNwp.size() - 96).getDirectRadiation());//直接辐射
+
+                    nwpData.setSenf(listNwp.get(listNwp.size() - 96).getSenf());//热感通量
+
+                    nwpData.setWs10(listNwp.get(listNwp.size() - 96).getWs10());//10 m 风速
+                    nwpData.setWs30(listNwp.get(listNwp.size() - 96).getWs30());//30 m 风速
+                    nwpData.setWs50(listNwp.get(listNwp.size() - 96).getWs50());//50 m 风速
+                    nwpData.setWs70(listNwp.get(listNwp.size() - 96).getWs70());//70 m 风速
+                    nwpData.setWs80(listNwp.get(listNwp.size() - 96).getWs80());//80 m 风速
+                    nwpData.setWs90(listNwp.get(listNwp.size() - 96).getWs90());//90 m 风速
+                    nwpData.setWs100(listNwp.get(listNwp.size() - 96).getWs100());//100 m 风速
+                    nwpData.setWs170(listNwp.get(listNwp.size() - 96).getWs170());//170 m 风速
+
+                    nwpData.setWd10(listNwp.get(listNwp.size() - 96).getWd10());//10 m 风向
+                    nwpData.setWd30(listNwp.get(listNwp.size() - 96).getWd30());//30 m 风向
+                    nwpData.setWd50(listNwp.get(listNwp.size() - 96).getWd50());//50 m 风向
+                    nwpData.setWd70(listNwp.get(listNwp.size() - 96).getWd70());//70 m 风向
+                    nwpData.setWd80(listNwp.get(listNwp.size() - 96).getWd80());//80 m 风向
+                    nwpData.setWd90(listNwp.get(listNwp.size() - 96).getWd90());//90 m 风向
+                    nwpData.setWd100(listNwp.get(listNwp.size() - 96).getWd100());//100 m 风向
+                    nwpData.setWd170(listNwp.get(listNwp.size() - 96).getWd170());//170 m 风向
+                    nwpData.setStationCode(stationCode);
+                    listNwp.add(nwpData);
+                  }
+                } else {
+                  flag = false;
+                  log.info(file.getName() + "文件数据内容为空、不能正常解析 、移除该文件、执行数据修正功能");
+                }
+                //保存NWP实时数据
+                Long startTime = listNwp.get(0).getPreTime();
+                Long endTime = listNwp.get(listNwp.size() - 1).getPreTime();//删除相同时间数据
+                nwpService.deleteBetweenAndPreTime(startTime, endTime, listNwp,stationCode);
+                flag = true;
+              } catch (Exception e) {
+                log.error("解析NWP文件失败", e);
+                flag = false;
+              }
+            }
+            if (flag) {
+              //文件解析成功之后,保存记录
+              saveFileParsingRecord(file, "1",stationCode);
+              //移除文件备份到临时文件下
+              moveFile(file);
+              if (startConsole){
+                //重启console程序
+                Runtime.getRuntime().exec("service console restart");
+              }
+            } else {
+              //文件解析失败之后,保存记录
+              saveFileParsingRecord(file, "0",stationCode);
+              //移除文件备份到error文件下
+              moveFileError(file);
+            }
+          }
+        }
+      } else {
+      }
+      log.info("-----------------执行文件解析任务完成----------------------");
+    }
+	}
+
+	public static void mvFile(File file, String fdPath) {
+		try {
+			FileUtils.copyFile(file, new File(fdPath), true);
+		} catch (IOException e) {
+			log.error("文件移动错误", e);
+		}
+	}
+
+	/**
+	 * NWP解析
+	 *
+	 * @param file 文件路径
+	 * @return 样例集合
+	 */
+	private List<Nwp> fileAnalysisNwp(File file,String stationCode) {
+		List<Nwp> listNwp = new ArrayList<>();
+		if (file.renameTo(file)) {
+			InputStreamReader readNwp = null;
+			BufferedReader bufferedReaderNwp = null;
+			try {
+				readNwp = new InputStreamReader(new FileInputStream(file), "utf-8");//考虑到编码格式
+				bufferedReaderNwp = new BufferedReader(readNwp);
+				String fileName = file.getName();
+				fileName = fileName.substring(fileName.indexOf("_") + 1, fileName.lastIndexOf("."));
+				String lineTxt;
+				Nwp nwpData = null;
+				BigDecimal nwpDirectRadiation = new BigDecimal(0.7); //直接辐射
+				BigDecimal nwpDiffuseRadiation = new BigDecimal(0.3); //散接辐射
+
+				while ((lineTxt = bufferedReaderNwp.readLine()) != null) {
+					//NWP文件按照Tab方式截取
+					String[] datas = lineTxt.split("\t");
+					if (datas.length == 35 && datas[0].startsWith("#")) {
+						SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+						if (datas != null && datas.length > 0) {
+							//过滤当天的数据
+							//if (sdf.parse(datas[5]).getTime() >= TimeUtils.getMillisecondsSubDay() + 24 * 60 * 60 *
+							// 1000) {
+							nwpData = new Nwp();
+
+							//将截取的文件放入nwpData中
+							nwpData.setFarmId(datas[1]);
+							nwpData.setScDate(datas[2]);
+							nwpData.setScTime(datas[3]);
+							nwpData.setPreDate(datas[4]);
+							nwpData.setPreTime(sdf.parse(datas[5]).getTime());//采集时间 与 短期预测时间关联
+							nwpData.setT(NumberUtils.subtract(new BigDecimal(datas[6]), new BigDecimal(273.15)));//温度
+
+							nwpData.setSenf(new BigDecimal(datas[11]).setScale(2, RoundingMode.HALF_UP));//感热
+							nwpData.setSwr(new BigDecimal(datas[9]).setScale(2, RoundingMode.HALF_UP));//短波辐射(相当于总辐射)
+							nwpData.setLwr(new BigDecimal(datas[10]).setScale(2, RoundingMode.HALF_UP));//短波辐射(相当于总辐射)
+							nwpData.setPressure(new BigDecimal(datas[8]).setScale(2, RoundingMode.HALF_UP));//地表气压
+							nwpData.setRh(new BigDecimal(datas[7]).setScale(2, RoundingMode.HALF_UP));//2m相对湿度
+							nwpData.setDiffuseRadiation(new BigDecimal(datas[9]).multiply(nwpDiffuseRadiation).setScale(2, RoundingMode.HALF_UP));//散接辐射
+							nwpData.setDirectRadiation(new BigDecimal(datas[9]).multiply(nwpDirectRadiation).setScale(2, RoundingMode.HALF_UP));//直接辐射
+
+							nwpData.setWs10(new BigDecimal(datas[19]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs30(new BigDecimal(datas[20]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs50(new BigDecimal(datas[21]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs70(new BigDecimal(datas[22]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs80(new BigDecimal(datas[23]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs90(new BigDecimal(datas[24]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs100(new BigDecimal(datas[25]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWs170(new BigDecimal(datas[26]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd10(new BigDecimal(datas[27]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd30(new BigDecimal(datas[28]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd50(new BigDecimal(datas[29]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd70(new BigDecimal(datas[30]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd80(new BigDecimal(datas[31]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd90(new BigDecimal(datas[32]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd100(new BigDecimal(datas[33]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setWd170(new BigDecimal(datas[34]).setScale(2, RoundingMode.HALF_UP));
+							nwpData.setStationCode(stationCode);
+							listNwp.add(nwpData);
+							//}
+						}
+					}
+				}
+			} catch (IOException | ParseException | RuntimeException e) {
+				log.error("系统错误:", e);
+				// 进行告警
+				String name = "NWP文件解析失败";
+				String describe = "请查看NWP文件格式是否正常";
+				String solution = "请修改NWP文件内容";
+				File destFile = new File(file.getPath().replaceFirst("new", "error"));
+				if (destFile.exists()) {
+					destFile.delete();
+				}
+				try {
+					FileUtils.moveFile(file, destFile);
+				} catch (IOException e1) {
+					log.error(file.getName() + "文件解析失败", e);
+				}
+			} finally {
+				close(bufferedReaderNwp, readNwp);
+			}
+		}
+		return listNwp;
+	}
+
+
+	/**
+	 * 假期解析
+	 *
+	 * @param file 文件路径
+	 * @return 样例集合
+	 */
+	private List<HolidayCalendar> fileAnalysisJqTerm(File file) {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		List<HolidayCalendar> holidayCalendars = new ArrayList<>();
+		// 当文件未被使用时,进行解析上报
+		if (file.renameTo(file)) {
+			InputStreamReader read = null;
+			BufferedReader bufferedReader = null;
+			String stringLine;
+			HolidayCalendar holiday;
+			try {
+				read = new InputStreamReader(new FileInputStream(file), "utf-8");
+				bufferedReader = new BufferedReader(read);
+				while ((stringLine = bufferedReader.readLine()) != null) {
+					String[] string_arr = stringLine.split("\t");
+					if (string_arr.length == 7 && string_arr[0].startsWith("#")) {
+						holiday = new HolidayCalendar();
+						holiday.setId(Integer.parseInt(string_arr[1] + ""));
+						holiday.setName(string_arr[2] + "");
+						holiday.setStartTime(sdf.parse(string_arr[3]).getTime());
+						holiday.setEndTime(sdf.parse(string_arr[4]).getTime());
+						holiday.setDays(Integer.parseInt(string_arr[5] + ""));
+						if (string_arr[6].equals("1")) {
+							holiday.setHolidayTypeEnum(HolidayTypeEnum.valueOf(string_arr[6]));
+						}
+						holidayCalendars.add(holiday);
+					}
+				}
+			} catch (IOException | ParseException | RuntimeException e) {
+				log.error("系统错误:", e);
+				// 进行告警
+				String name = "假期文件解析失败";
+				String describe = "请查看假期文件格式是否正常";
+				String solution = "请修改假期文件内容";
+
+				File destFile = new File(file.getPath().replaceFirst("new", "error"));
+				if (destFile.exists()) {
+					destFile.delete();
+				}
+				try {
+					FileUtils.moveFile(file, destFile);
+				} catch (IOException e1) {
+					log.error(file.getName() + "文件解析失败", e);
+				}
+			} finally {
+				close(bufferedReader, read);
+			}
+		}
+		return holidayCalendars;
+	}
+
+	/**
+	 * 短期解析
+	 *
+	 * @param file        文件路径
+	 * @param currentDate 当前时间
+	 * @return 样例集合
+	 */
+	private List<ForecastPowerShortTerm> fileAnalysisShortTerm(File file, Long currentDate,String stationCode) {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		List<ForecastPowerShortTerm> forecastPowerShortTerm = new ArrayList<>();
+		// 当文件未被使用时,进行解析上报
+		if (file.renameTo(file)) {
+			InputStreamReader read = null;
+			BufferedReader bufferedReader = null;
+			String stringLine;
+			ForecastPowerShortTerm stf;
+			try {
+				read = new InputStreamReader(new FileInputStream(file), "utf-8");
+				bufferedReader = new BufferedReader(read);
+				while ((stringLine = bufferedReader.readLine()) != null) {
+					String[] string_arr = stringLine.split("\t");
+
+              if (string_arr.length == 4 && string_arr[0].startsWith("#")) {
+                if (StringUtils.isNotEmpty(string_arr[2])) {
+                  //过滤当天的数据
+                //if (sdf.parse(string_arr[2]).getTime() >= TimeUtils.getMillisecondsSubDay() + 24 * 60 *
+                // 60 * 1000) {
+                stf = new ForecastPowerShortTerm();
+                stf.setFpValue(new BigDecimal(string_arr[3] + ""));
+                stf.setForecastTime(sdf.parse(string_arr[2]).getTime());
+                stf.setGenDate(new Date(currentDate));
+                stf.setPredictionModelEnum(PredictionModelEnum.E1);
+                stf.setStationCode(stationCode);
+                forecastPowerShortTerm.add(stf);
+                // }
+						}
+					}
+				}
+			} catch (IOException | ParseException | RuntimeException e) {
+				log.error("系统错误:", e);
+				// 进行告警
+				File destFile = new File(file.getPath().replaceFirst("new", "error"));
+				if (destFile.exists()) {
+					destFile.delete();
+				}
+				try {
+					FileUtils.moveFile(file, destFile);
+				} catch (IOException e1) {
+					log.error(file.getName() + "文件解析失败", e);
+				}
+			} finally {
+				close(bufferedReader, read);
+			}
+		}
+		return forecastPowerShortTerm;
+	}
+
+	/**
+	 * 移动文件到临时目录下
+	 *
+	 * @param file 文件
+	 */
+	private void moveFile(File file) {
+		// 移动文件到处理目录
+		File destFile = new File(file.getPath().replaceFirst("new", "backupsTemp"));
+		log.info("move file :{}, dest file:{}", file, destFile);
+		if (destFile.exists()) {
+			destFile.delete();
+		}
+		try {
+			FileUtils.moveFile(file, destFile);
+		} catch (IOException e) {
+			log.error("系统移除文件错误:", e);
+			// 进行告警
+		}
+		moveFileBackups(destFile.getParent());
+	}
+
+	/**
+	 * 移动文件到处理目录
+	 *
+	 * @param filePath 文件路径
+	 */
+	private void moveFileBackups(String filePath) {
+		String targetRoot = filePath.replaceFirst("backupsTemp", "backups");
+		String path = mkDirForTime(targetRoot, null);
+		path = mkDirForTime(path, "yyyyMMdd");
+		// 移动文件夹内容
+		File sourceFile = new File(filePath);
+		if (sourceFile.exists()) {
+			try {
+				File[] files = sourceFile.listFiles();
+				if (files != null && files.length > 0) {
+					for (File f : files) {
+						if (f.renameTo(new File(path + f.getName()))) {
+							log.info("move file :{}, dest file:{}", path, f.getName());
+						}
+					}
+				}
+			} catch (Exception e) {
+				// 进行告警
+			}
+		}
+	}
+
+	/**
+	 * 移动文件到处理错误目录下
+	 *
+	 * @param file 文件
+	 */
+	private void moveFileError(File file) {
+		File destFile = new File(file.getPath().replaceFirst("new", "error"));
+		if (destFile.exists()) {
+			destFile.delete();
+		}
+		try {
+			FileUtils.moveFile(file, destFile);
+		} catch (IOException e) {
+			log.error(file.getName() + "文件解析失败", e);
+		}
+	}
+
+	/**
+	 * 创建备份文件夹
+	 *
+	 * @param targetRoot
+	 * @param format
+	 * @return
+	 */
+	public static String mkDirForTime(String targetRoot, String format) {
+		String path = null;
+		File file = null;
+		if (StringUtils.isNotEmpty(format)) {
+			Long current = System.currentTimeMillis();
+			path = DateFormatUtils.format(current, format);
+			file = new File(targetRoot + File.separator + path + File.separator);
+
+		} else {
+			file = new File(targetRoot + File.separator);
+		}
+
+		if (!file.exists() && !file.isFile()) {
+
+			if (file.mkdir()) {
+				log.info("已创建文件夹");
+			} else {
+				log.info("创建文件夹失败,路径:" + file.getPath());
+			}
+		}
+		return file.getPath() + File.separator;
+	}
+
+	/**
+	 * 保存文件解析记录
+	 *
+	 * @param file       文件信息
+	 * @param fileStatus 文件解析状态 1:表示解析成功 0:解析失败
+	 */
+	private void saveFileParsingRecord(File file, String fileStatus,String staticCode) {
+		String fileType = "";
+		if (file.getName().startsWith("JH")) {
+			fileType = "JH";//假期文件
+		} else if (file.getName().startsWith("DQ")) {
+			fileType = "DQ";//短期文件
+		} else {
+			fileType = "NWP";//NWP文件
+		}
+		FileAnalysisRecord fileParsingRecord = new FileAnalysisRecord();
+		fileParsingRecord.setFileTitle(file.getName());
+		fileParsingRecord.setFileType(fileType);
+		fileParsingRecord.setFileStatus(fileStatus);
+		fileParsingRecord.setFilePath(file.getPath());
+		fileParsingRecord.setFileDescription(DateTimeUtil.getStringDate() + " 正常解析文件");
+		fileParsingRecord.setStationCode(staticCode);
+		fileAnalysisRecordService.save(fileParsingRecord);
+	}
+
+
+	/**
+	 * 关闭文件流
+	 *
+	 * @param bufferedReader 字符数据
+	 * @param read           字节流
+	 */
+	private void close(BufferedReader bufferedReader, InputStreamReader read) {
+		try {
+			if (bufferedReader != null) {
+				bufferedReader.close();
+			}
+			if (read != null) {
+				read.close();
+			}
+		} catch (IOException e) {
+			log.error("关闭文件流失败:", e);
+		}
+	}
+}

+ 121 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/HolidayCalendarService.java

@@ -0,0 +1,121 @@
+package com.jiayue.ipfcst.console.service;
+
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.data.entity.HolidayCalendar;
+import com.jiayue.ipfcst.common.data.repository.HolidayCalendarRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.*;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 假期日历业务类
+ *
+ * @author tl
+ * @version 1.0
+ * @since 2020/03/11 9:49
+ */
+@Service
+@Slf4j
+public class HolidayCalendarService extends BaseService {
+  private final HolidayCalendarRepository holidayCalendarRepository;
+
+  @Autowired
+  public HolidayCalendarService(HolidayCalendarRepository holidayCalendarRepository) {
+    this.holidayCalendarRepository = holidayCalendarRepository;
+  }
+
+  /**
+   * 新增假期日历信息
+   *
+   * @param holidayCalendar 假期日历信息
+   */
+  public void save(HolidayCalendar holidayCalendar)
+    throws BusinessException {
+    this.holidayCalendarRepository.save(holidayCalendar);
+  }
+
+  /**
+   * 删除假期日历信息
+   */
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
+  public void delete(final Integer id) throws BusinessException {
+    this.holidayCalendarRepository.deleteById(id);
+  }
+
+  /**
+   * 修改假期日历信息
+   */
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
+  public void update(HolidayCalendar holidayCalendar)
+    throws BusinessException {
+    if (holidayCalendar.getId() == null) {
+      throw new BusinessException("日历编号不能为空");
+    } else {
+      this.holidayCalendarRepository.save(holidayCalendar);
+    }
+  }
+
+  /**
+   * 分页查询
+   */
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS, readOnly = true)
+  public Page<HolidayCalendar> get(
+    final HolidayCalendar holidayCalendar, final Integer page, final Integer size) {
+    ExampleMatcher matcher =
+      ExampleMatcher.matching().withMatcher("id", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<HolidayCalendar> example = Example.of(holidayCalendar, matcher);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    return this.holidayCalendarRepository.findAll(example, pageable);
+
+  }
+
+
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS, readOnly = true)
+  public List<HolidayCalendar> getAll() {
+
+    return this.holidayCalendarRepository.findAll();
+
+  }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void saveCloud(List<HolidayCalendar> beans) {
+        holidayCalendarRepository.deleteAll();
+        holidayCalendarRepository.saveAll(beans);
+    }
+
+  /**
+   * 计算出距离当前最近且在当前时间之后的时间
+   * @return
+   */
+  public HolidayCalendar findByNextTime(){
+
+    List<HolidayCalendar> holidayCalendarList = holidayCalendarRepository.findAll();
+    HolidayCalendar holidayCalendar1 = new HolidayCalendar();
+    holidayCalendar1.setStartTime(0l);
+    if(holidayCalendarList.size()>0){
+
+      Long time = System.currentTimeMillis();
+      for(HolidayCalendar holidayCalendar:holidayCalendarList){
+        Long difference = holidayCalendar.getStartTime() - time;
+        if(holidayCalendar.getStartTime()>time){
+          if(holidayCalendar1.getStartTime()==0){
+//          holidayCalendar1.setStartTime(difference);
+            holidayCalendar1 = holidayCalendar;
+          }
+          if(difference>0l&&difference<holidayCalendar1.getStartTime()){
+            holidayCalendar1 = holidayCalendar;
+          }
+        }
+
+      }
+    }
+
+    return holidayCalendar1;
+  }
+}

+ 194 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java

@@ -0,0 +1,194 @@
+package com.jiayue.ipfcst.console.service;
+
+
+import com.jiayue.ipfcst.common.core.util.CommonUtil;
+import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
+import com.jiayue.ipfcst.common.data.entity.Nwp;
+import com.jiayue.ipfcst.common.data.entity.NwpHis;
+import com.jiayue.ipfcst.common.data.repository.NwpHisRepository;
+import com.jiayue.ipfcst.common.data.repository.NwpRepository;
+import com.jiayue.ipfcst.common.data.service.BaseService;
+import com.sun.istack.internal.NotNull;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class NwpService extends BaseService {
+
+    @Autowired
+    NwpRepository nwpRepository;
+    @Autowired
+    NwpHisRepository nwpHisRepository;
+
+
+    /**
+     * 保存全部
+     *
+     * @param listNwp
+     */
+    public void saveAll(List<Nwp> listNwp) {
+        nwpRepository.saveAll(listNwp);
+    }
+
+    /**
+     * 根据时间段删除数据
+     *
+     * @param startTime
+     * @param endTime
+     * @param listNwp
+     */
+    @Transactional(propagation = Propagation.REQUIRED)
+    public void deleteBetweenAndPreTime(Long startTime, Long endTime, List<Nwp> listNwp,String stationCode) {
+        nwpRepository.deleteByPreTimeBetweenAndStationCode(startTime, endTime,stationCode);
+        nwpRepository.saveAll(listNwp);
+    }
+
+    /**
+     * 查询NWP数据,当查询结果不足时,需要本地化生成NWP数据并保存到数据库中,用于NWP数据上报时使用
+     *
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     * @return NWP数据结果集
+     */
+    @Transactional(propagation = Propagation.REQUIRED)
+    public List<Nwp> getNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
+        log.info("开始获取NWP数据" + DateFormatUtils.format(startTime, "yyyy-MM-dd HH:mm:ss") + " 至 " + DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
+        // 查询NWP数据
+        List<Nwp> nwpDataList = this.nwpRepository.findByPreTimeBetween(startTime, endTime);
+        nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));// 按预测时间升序
+        log.info("查询现有NWP数据记录数:" + nwpDataList.size());
+        // 判断查询结果是否满足查询所需
+        Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
+        Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
+        log.info("获取所需记录数:" + moments);
+        if (moments > nwpDataList.size()) {
+            // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
+            Map<Long, List<Nwp>> nwpDataMap = nwpDataList.stream().collect(Collectors.groupingBy(Nwp::getPreTime));
+            // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
+            List<Nwp> addNwpDataList = new ArrayList<>();
+            for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
+                if (nwpDataMap.get(tempTime) == null) {
+                    // 缺失时间点
+                    List<Nwp> _nwpDataList = this.generateNwpData(tempTime);
+                    addNwpDataList.addAll(_nwpDataList);
+                }
+            }
+
+            if (!addNwpDataList.isEmpty()) {
+                this.nwpRepository.saveAll(addNwpDataList);
+                // 将补齐的NWP数据追加到查询结果集中
+                nwpDataList.addAll(addNwpDataList);
+                // 进行告警
+                String errorInfo = "NWP数据不足";
+                log.error(errorInfo);
+                // 进行告警
+                String name = "NWP数据不足";
+                String describe = "";
+                String solution = "请检查NWP数据下载软件";
+                //super.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution);
+            }
+
+        }
+        // 处理NWP历史数据记录
+        List<NwpHis> nwpDataHiss = new ArrayList<>();
+        NwpHis nwpHis;
+        Long systemTime = new Date().getTime();
+
+        for (Nwp nwp : nwpDataList) {
+            nwpHis = new NwpHis();
+            BeanUtils.copyProperties(nwp, nwpHis);
+            // 设置提前几天预测
+            nwpHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime, nwpHis.getPreTime()));
+            nwpDataHiss.add(nwpHis);
+        }
+        // 按预测时间升序
+        nwpDataHiss.sort(Comparator.comparing(NwpHis::getPreTime));
+        // 删除当日生成的短期历史记录
+        this.nwpHisRepository.deleteToday(startTime, endTime);
+        // 保存NWP历史记录
+        this.nwpHisRepository.saveAll(nwpDataHiss);
+        return nwpDataList;
+    }
+
+    /**
+     * 生成NWP数据,NWP数据为云下载数据,这里不进行覆盖更新,只针对NWP数据不足时补充
+     *
+     * @param startTime 开始时间
+     * @param endTime   结束时间
+     */
+    @Transactional(propagation = Propagation.REQUIRED)
+    public void buildNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
+        this.getNwpData(startTime, endTime);
+    }
+
+    /**
+     * 生成NWP数据
+     *
+     * @return nwp数据集
+     */
+    @Transactional(propagation = Propagation.REQUIRED)
+    private List<Nwp> generateNwpData(@NotNull final Long tempTime) {
+
+        List<Nwp> nwpDataList;
+
+        // 使用历史NWP数据生成NWP数据
+        List<Nwp> result = new ArrayList<>();
+        // 查询前一天同时刻NWP数据
+        nwpDataList = this.nwpRepository.findByPreTimeBetween(tempTime - 24 * 60 * 60 * 1000L, tempTime - 24 * 50 * 60 * 1000L);
+        if (nwpDataList.size() > 0) {
+            Nwp nwp = new Nwp();
+            BeanUtils.copyProperties(nwpDataList.get(0), nwp, "id");
+            nwp.setPreTime(tempTime);
+            nwp.setPreDate(DateFormatUtils.format(tempTime, "yyyy-MM-dd"));
+            result.add(nwp);
+        } else {// 如果未查询到前一天数据,则随机生成NWP数据
+            result.add(this.createNwpData(tempTime));
+        }
+        return result;
+    }
+
+    private Nwp createNwpData(Long preTime) {
+        Long systemTime = System.currentTimeMillis();
+        Nwp nwpData = new Nwp();
+        nwpData.setFarmId("1");
+        nwpData.setScDate(DateFormatUtils.format(systemTime, "yyyy-MM-dd"));
+        nwpData.setScTime(DateFormatUtils.format(systemTime, "HH:mm:ss"));
+        nwpData.setPreTime(preTime);
+        nwpData.setPreDate(DateFormatUtils.format(preTime, "yyyy-MM-dd"));
+        nwpData.setPressure(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setT(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setRh(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setSenf(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setSwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setLwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+
+        nwpData.setWd10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWd170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        nwpData.setWs170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2,BigDecimal.ROUND_UP));
+        return nwpData;
+    }
+}