فهرست منبع

重新编写解析FTP短期规则,更改项目中所有localdatetime改为date类型

xusl 10 ماه پیش
والد
کامیت
41fa3cb09e
15فایلهای تغییر یافته به همراه225 افزوده شده و 198 حذف شده
  1. 10 1
      ipp-common/ipp-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java
  2. 5 6
      ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerShortTerm.java
  3. 4 4
      ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerShortTermHis.java
  4. 3 2
      ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerUltraShortTerm.java
  5. 3 3
      ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerUltraShortTermHis.java
  6. 57 0
      ipp-common/ipp-common-mybatis/src/main/java/com/jiayue/ipp/common/mybatis/base/NotLogicBaseEntity.java
  7. 6 6
      ipp-idp/src/main/java/com/jiayue/ipp/idp/api/CallForecastPowerUltraShortTermApi.java
  8. 2 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/api/ForecastDataApi.java
  9. 5 4
      ipp-idp/src/main/java/com/jiayue/ipp/idp/dto/ForecastDataApiDto.java
  10. 1 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/job/ParsingJob.java
  11. 35 87
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/an/FTPService.java
  12. 2 2
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/AccuracyCalculationServiceImpl.java
  13. 3 3
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/PowerStationStatusDataServiceImpl.java
  14. 7 5
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingCdqInfoServiceImpl.java
  15. 82 73
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingDqInfoServiceImpl.java

+ 10 - 1
ipp-common/ipp-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java

@@ -1,6 +1,8 @@
 package com.jiayue.ipfcst.common.core.util;
 
 
+import cn.hutool.core.date.DateUtil;
+
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -158,7 +160,14 @@ public abstract class DateMomentUtil {
      * @return 自然天数
      */
     public static Integer getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {
-        return (int) ((DateMomentUtil.getDayStartTime(dateTo) - DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
+        int a = (int) ((DateMomentUtil.getDayStartTime(dateTo) - DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
+        if (a==2){
+            System.out.println(dateTo);
+            System.out.println(DateMomentUtil.getDayStartTime(dateTo));
+            System.out.println(DateUtil.format(new Date(dateTo),"yyyy-MM-dd HH:mm:ss"));
+            System.out.println("##############################################");
+        }
+        return a;
     }
 
 

+ 5 - 6
ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerShortTerm.java

@@ -4,15 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.jiayue.ipp.common.mybatis.base.BaseDataEntity;
+import com.jiayue.ipp.common.mybatis.base.NotLogicBaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
+import java.util.Date;
 
 import javax.validation.constraints.Digits;
 
@@ -26,7 +25,7 @@ import javax.validation.constraints.Digits;
 @TableName("idp_forecast_power_short_term")
 @EqualsAndHashCode(callSuper = true)
 @ApiModel(value = "idp_forecast_power_short_term")
-public class ForecastPowerShortTerm extends BaseDataEntity<ForecastPowerShortTerm> {
+public class ForecastPowerShortTerm extends NotLogicBaseEntity<ForecastPowerShortTerm> {
     private static final long serialVersionUID = 1L;
 
 
@@ -42,7 +41,7 @@ public class ForecastPowerShortTerm extends BaseDataEntity<ForecastPowerShortTer
      * 数据生成日期
      */
     @ApiModelProperty(value = "数据生成日期")
-    private LocalDate genDate;
+    private Date genDate;
 
 
     /**
@@ -50,7 +49,7 @@ public class ForecastPowerShortTerm extends BaseDataEntity<ForecastPowerShortTer
      */
     @ApiModelProperty(value = "预测时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime forecastTime;
+    private Date forecastTime;
 
 
     /**

+ 4 - 4
ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerShortTermHis.java

@@ -3,7 +3,7 @@ package com.jiayue.ipp.common.data.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.jiayue.ipp.common.mybatis.base.BaseDataEntity;
+import com.jiayue.ipp.common.mybatis.base.NotLogicBaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
+import java.util.Date;
 
 import javax.validation.constraints.Digits;
 
@@ -25,7 +25,7 @@ import javax.validation.constraints.Digits;
 @TableName("idp_forecast_power_short_term_his")
 @EqualsAndHashCode(callSuper = true)
 @ApiModel(value = "idp_forecast_power_short_term_his")
-public class ForecastPowerShortTermHis extends BaseDataEntity<ForecastPowerShortTermHis> {
+public class ForecastPowerShortTermHis extends NotLogicBaseEntity<ForecastPowerShortTermHis> {
     private static final long serialVersionUID = 1L;
 
 
@@ -48,7 +48,7 @@ public class ForecastPowerShortTermHis extends BaseDataEntity<ForecastPowerShort
      * 预测时间
      */
     @ApiModelProperty(value = "预测时间")
-    private LocalDateTime forecastTime;
+    private Date forecastTime;
 
 
     /**

+ 3 - 2
ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerUltraShortTerm.java

@@ -12,6 +12,7 @@ import lombok.EqualsAndHashCode;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 import javax.validation.constraints.Digits;
 
@@ -41,14 +42,14 @@ public class ForecastPowerUltraShortTerm extends BaseDataEntity<ForecastPowerUlt
      * 数据生成日期
      */
     @ApiModelProperty(value = "数据生成日期")
-    private LocalDate genDate;
+    private Date genDate;
 
 
     /**
      * 预测时间
      */
     @ApiModelProperty(value = "预测时间")
-    private LocalDateTime forecastTime;
+    private Date forecastTime;
 
 
     /**

+ 3 - 3
ipp-common/ipp-common-data/src/main/java/com/jiayue/ipp/common/data/entity/ForecastPowerUltraShortTermHis.java

@@ -10,8 +10,8 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 import javax.validation.constraints.Digits;
 
@@ -41,14 +41,14 @@ public class ForecastPowerUltraShortTermHis extends BaseDataEntity<ForecastPower
      * 生成日期
      */
     @ApiModelProperty(value = "生成日期")
-    private LocalDate genDate;
+    private Date genDate;
 
 
     /**
      * 预测时间
      */
     @ApiModelProperty(value = "预测时间")
-    private LocalDateTime forecastTime;
+    private Date forecastTime;
 
 
     /**

+ 57 - 0
ipp-common/ipp-common-mybatis/src/main/java/com/jiayue/ipp/common/mybatis/base/NotLogicBaseEntity.java

@@ -0,0 +1,57 @@
+package com.jiayue.ipp.common.mybatis.base;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * mybatis entity 基础entity
+ * @param <T> 继承者
+ */
+@Data
+public class NotLogicBaseEntity<T extends Model<?>> extends Model<T> {
+
+	/**
+	 * 数据权限存放map
+	 */
+
+	@TableField(exist = false)
+	Map<String,String> Params = new HashMap<>();
+	/**
+	 * 创建者
+	 */
+	@TableField(fill = FieldFill.INSERT)
+	private String creator;
+	/**
+	 * 创建时间
+	 */
+
+	@TableField( fill = FieldFill.INSERT)
+	private LocalDateTime createTime;
+	/**
+	 * 最后修改者
+	 */
+
+	@TableField(fill = FieldFill.INSERT_UPDATE)
+	private String lastModifier;
+	/**
+	 * 最后修改时间
+	 */
+
+	@TableField(fill = FieldFill.INSERT_UPDATE)
+	private LocalDateTime lastModifyTime;
+
+	@TableField(fill = FieldFill.INSERT)
+	private String delFlag;
+
+	/**
+	 * 场站标识
+	 */
+	private String stationCode;
+}

+ 6 - 6
ipp-idp/src/main/java/com/jiayue/ipp/idp/api/CallForecastPowerUltraShortTermApi.java

@@ -135,7 +135,7 @@ public class CallForecastPowerUltraShortTermApi {
                     ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
                     forecastPowerUltraShortTerm.setFpValue(responseApiBean.getPredict().get(i).setScale(2, BigDecimal.ROUND_HALF_UP));
                     forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTerms.get(i).getForecastTime());
-                    forecastPowerUltraShortTerm.setGenDate(LocalDate.now());
+                    forecastPowerUltraShortTerm.setGenDate(new Date());
                     forecastPowerUltraShortTerm.setForecastManufactor("SYJY");
                     forecastPowerUltraShortTerm.setStationCode(stationCode);
 //          forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E3);
@@ -222,7 +222,7 @@ public class CallForecastPowerUltraShortTermApi {
                 // 查询该时间段内的短期预测功率
                 List<ForecastPowerShortTerm> forecastPowerShortTermList = this.forecastPowerShortTermService.findByStationCodeAndStartTimeAndEndTime(stationCode, new Date(startTime), new Date(endTime));
 
-                Map<LocalDateTime, List<ForecastPowerShortTerm>> forecastPowerShortTermsMap =
+                Map<Date, List<ForecastPowerShortTerm>> forecastPowerShortTermsMap =
                         forecastPowerShortTermList.stream().collect(Collectors.groupingBy(ForecastPowerShortTerm::getForecastTime));
 
 //            List<ForecastPowerShortTerm> addForecastPowerShortTermList = new ArrayList<>();
@@ -321,7 +321,7 @@ public class CallForecastPowerUltraShortTermApi {
             for (int i = 0; i < forecastPowerShortTermList.size(); i++) {
                 forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
                 forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
-                forecastPowerUltraShortTerm.setGenDate(LocalDate.now());
+                forecastPowerUltraShortTerm.setGenDate(new Date());
                 forecastPowerUltraShortTerm.setForecastManufactor("SYJY");
                 forecastPowerUltraShortTerm.setStationCode(stationCode);
                 //短期
@@ -371,7 +371,7 @@ public class CallForecastPowerUltraShortTermApi {
                 forecastPowerUltraShortTerm.setCoefficientValue(ustPower);
                 forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
                 forecastPowerUltraShortTerm.setFpValue(ustPower);
-                forecastPowerUltraShortTerm.setGenDate(LocalDate.now());
+                forecastPowerUltraShortTerm.setGenDate(new Date());
                 forecastPowerUltraShortTerm.setStationCode(stationCode);
                 forecastPowerUltraShortTerm.setForecastManufactor("SYJY");
                 forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
@@ -380,8 +380,8 @@ public class CallForecastPowerUltraShortTermApi {
 
         if (forecastPowerUltraShortTermList.size() > 0) {
             // 获取数据开始时间和结束时间
-            LocalDateTime oldStarTime = forecastPowerUltraShortTermList.get(0).getForecastTime();
-            LocalDateTime oldEndTime = forecastPowerUltraShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime();
+            Date oldStarTime = forecastPowerUltraShortTermList.get(0).getForecastTime();
+            Date oldEndTime = forecastPowerUltraShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime();
 
 
             // 保存超短期预测结果

+ 2 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/api/ForecastDataApi.java

@@ -1,5 +1,6 @@
 package com.jiayue.ipp.idp.api;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTerm;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTermHis;
@@ -193,7 +194,7 @@ public class ForecastDataApi {
                 if (count == 4) {
                     double average = sum / count;
                     ForecastData forecastData = new ForecastData();
-                    forecastData.setTime(DateFormatUtils.format(DateTypeConversionUtils.localDateTimeToDate(forecastPowerShortTerm.getForecastTime()), "yyyy-MM-dd HH"));
+                    forecastData.setTime(DateUtil.format(forecastPowerShortTerm.getForecastTime(), "yyyy-MM-dd HH"));
                     forecastData.setPower(df.format(average));
                     forecastDatas.add(forecastData);
                     count = 0;

+ 5 - 4
ipp-idp/src/main/java/com/jiayue/ipp/idp/dto/ForecastDataApiDto.java

@@ -1,5 +1,6 @@
 package com.jiayue.ipp.idp.dto;
 
+import cn.hutool.core.date.DateUtil;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTerm;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTermHis;
 import com.jiayue.ipp.common.data.entity.ForecastPowerUltraShortTerm;
@@ -53,7 +54,7 @@ public class ForecastDataApiDto<T> {
                 list.forEach(f -> {
                     ForecastData forecastData = new ForecastData();
                     forecastData.setPower(f.getFpValue().toString());
-                    forecastData.setTime(DateFormatUtils.format(DateTypeConversionUtils.localDateTimeToDate(f.getForecastTime()), "yyyy-MM-dd HH:mm"));
+                    forecastData.setTime(DateUtil.format(f.getForecastTime(), "yyyy-MM-dd HH:mm"));
                     this.forecastData.add(forecastData);
                 });
             }
@@ -62,7 +63,7 @@ public class ForecastDataApiDto<T> {
                 list.forEach(f -> {
                     ForecastData forecastData = new ForecastData();
                     forecastData.setPower(f.getFpValue().toString());
-                    forecastData.setTime(DateFormatUtils.format(DateTypeConversionUtils.localDateTimeToDate(f.getForecastTime()), "yyyy-MM-dd HH:mm"));
+                    forecastData.setTime(DateUtil.format(f.getForecastTime(), "yyyy-MM-dd HH:mm"));
                     this.forecastData.add(forecastData);
                 });
             }
@@ -71,7 +72,7 @@ public class ForecastDataApiDto<T> {
                 list.forEach(f -> {
                     ForecastData forecastData = new ForecastData();
                     forecastData.setPower(f.getAbleValue().toString());
-                    forecastData.setTime(DateFormatUtils.format(DateTypeConversionUtils.localDateTimeToDate(f.getForecastTime()), "yyyy-MM-dd HH:mm"));
+                    forecastData.setTime(DateUtil.format(f.getForecastTime(), "yyyy-MM-dd HH:mm"));
                     this.forecastData.add(forecastData);
                 });
             }
@@ -80,7 +81,7 @@ public class ForecastDataApiDto<T> {
                 list.forEach(f -> {
                     ForecastData forecastData = new ForecastData();
                     forecastData.setPower(f.getAbleValue().toString());
-                    forecastData.setTime(DateFormatUtils.format(DateTypeConversionUtils.localDateTimeToDate(f.getForecastTime()), "yyyy-MM-dd HH:mm"));
+                    forecastData.setTime(DateUtil.format(f.getForecastTime(), "yyyy-MM-dd HH:mm"));
                     this.forecastData.add(forecastData);
                 });
             }

+ 1 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/job/ParsingJob.java

@@ -34,7 +34,7 @@ public class ParsingJob {
     }
 
 //    @Scheduled(fixedRate = 900000)
-    @Scheduled(fixedRate = 60000)
+    @Scheduled(fixedDelay = 60000)
     void start(){
 //        redisUtil.setWithExpire(Constant.PKEY,"true",300l, TimeUnit.SECONDS);
 

+ 35 - 87
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/an/FTPService.java

@@ -99,102 +99,50 @@ public class FTPService {
                 try {
                     //遍历解析路径,对文件进行解析
                     for (ParsingUrl ftpParsingUrl : ftpParsingUrlList) {
-
                         String url = ftpParsingUrl.getUrl();
-
-                        String path = FileUtil.getParsingPath() + File.separator + ftpParsingUrl.getForecastManufactor();
-
+                        String path = FileUtil.getParsingPath() + File.separator + ftpParsingUrl.getForecastManufactor() + File.separator + ftpParsingUrl.getStationCode();
                         File dirFile = new File(path);
                         if (!dirFile.exists()) {
                             dirFile.mkdirs();
                         }
 
-//                        String bakPath = FileUtil.getParsingPath() + File.separator + "bak" + File.separator + simpleDateFormat.format(new Date()) + File.separator + ftpParsingUrl.getForecastManufactor() + File.separator;
-//                        File bakPathFile = new File(bakPath);
-//                        if (!bakPathFile.exists()) {
-//                            bakPathFile.mkdir();
-//                        }
-
                         if (ftp.existFile(url)) {
-                            List<FTPFile> ftpFiles = ftp.lsFiles(url, new Filter<FTPFile>() {
-                                @Override
-                                public boolean accept(FTPFile ftpFile) {
-                                    return true;
-                                }
-                            });
-
+//                            List<FTPFile> ftpFiles = ftp.lsFiles(url, new Filter<FTPFile>() {
+//                                @Override
+//                                public boolean accept(FTPFile ftpFile) {
+//                                    return true;
+//                                }
+//                            });
+                            List<String> strings = ftp.ls(url);
                             //遍历文件
-                            for (FTPFile fTPFile : ftpFiles) {
-                                if (!fTPFile.isDirectory()) {
-                                    String fileName = fTPFile.getName();
-                                    ParsingLog parsingLog = new ParsingLog();
-                                    parsingLog.setFileName(fileName);
-                                    parsingLog.setStationCode(ftpParsingUrl.getStationCode());
-                                    parsingLog.setParsingTime(new Date());
-
-                                    //下载文件到临时目录
-                                    ftp.download(url, fileName, dirFile);
-                                    File file = FileUtils.getFile(dirFile, fileName);
-
-                                    //定义解析的类型,默认为错误(未知),成功后为文件类型,也会作为存储目录名
-                                    String type = ParsingConstant.FAIL;
-                                    if (fileName.endsWith("status.json")) {
-                                        type = parsingStatusFile(file, ftpParsingUrl);
-                                    } else {
-                                        type = parsingFileService.parsingFile(file, ftpParsingUrl);
-
-                                    }
-                                    if (!type.startsWith(ParsingConstant.FAIL)) {
-                                        parsingLog.setFileType(type);
-//                                        //minio路径
-//                                        String foldPath = "/" + simpleDateFormat.format(new Date())
-//                                                + "/" + ftpParsingUrl.getStationCode()
-//                                                + "/" + type
-//                                                + "/" + ftpParsingUrl.getForecastManufactor()
-//                                                + "/" + file.getName();
-
-                                        //将文件上传到minIO
-//                                        if (minioUp(foldPath, file)) {
-//
-//                                            DaMinioFile daMinioFile = new DaMinioFile();
-//
-//                                            daMinioFile.setBucketName(bucketName);
-//                                            daMinioFile.setFileName(file.getName());
-//                                            daMinioFile.setFilePath(foldPath);
-//                                            daMinioFile.setFileState("0");
-//                                            daMinioFile.setFileType(type);
-//                                            daMinioFile.setStationCode(ftpParsingUrl.getStationCode());
-//                                            daMinioFile.setCompanySign(ftpParsingUrl.getForecastManufactor());
-//
-//                                            daMinioFileMapper.insert(daMinioFile);
-//
-////                                            ftp.changeWorkingDirectory("/lshrabbitMQ/hw_data");
-
-                                            boolean b = ftp.delFile(url + "/" + fileName);
-                                            if (b) {
-                                                FileUtils.forceDelete(file);
-//                                            FileUtils.moveFile(file, new File(bakPath + File.separator + fileName));
-                                                parsingLog.setParsingFileStatus("1");
-                                                parsingLog.setParsingDescribe("文件解析成功");
-                                            } else {
-                                                file.delete();
-                                                log.error(ftpParsingChannel.getChannelName() + "ftp文件删除失败,本地文件删除,等待下次下载");
-                                                parsingLog.setParsingFileStatus("0");
-                                                parsingLog.setParsingDescribe(ftpParsingChannel.getChannelName() + "ftp文件删除失败,本地文件删除,等待下次下载");
-                                            }
-                                        } else {
-                                            file.delete();
-                                            log.error("minio上传失败,本地文件删除,等待下次下载");
-                                            parsingLog.setParsingFileStatus("0");
-                                            parsingLog.setParsingDescribe("minio上传失败,本地文件删除,等待下次下载");
-                                        }
-//                                    } else {
-//                                        parsingLog.setParsingFileStatus("0");
-//                                        //失败情况下会返回失败信息
-//                                        parsingLog.setParsingDescribe(type);
-//                                    }
-                                    parsingLogService.save(parsingLog);
+                            for (String fileName : strings) {
+//                                if (!fTPFile.isDirectory()) {
+//                                    String fileName = fTPFile.getName();
+                                ParsingLog parsingLog = new ParsingLog();
+                                parsingLog.setFileName(fileName);
+                                parsingLog.setStationCode(ftpParsingUrl.getStationCode());
+                                parsingLog.setParsingTime(new Date());
+
+                                //下载文件到临时目录
+                                ftp.download(url, fileName, dirFile);
+                                File file = FileUtils.getFile(dirFile, fileName);
+
+                                //定义解析的类型,默认为错误(未知),成功后为文件类型,也会作为存储目录名
+                                String type = parsingFileService.parsingFile(file, ftpParsingUrl);
+                                parsingLog.setFileType(type);
+                                if (type.startsWith(ParsingConstant.FAIL)) {
+                                    // 解析失败
+                                    file.delete();
+                                    parsingLog.setParsingFileStatus("0");
+                                    parsingLog.setParsingDescribe("文件解析失败");
+                                }
+                                else{
+                                    // 解析成功,删除ftp上的文件
+                                    ftp.delFile(url + "/" + fileName);
+                                    parsingLog.setParsingFileStatus("1");
+                                    parsingLog.setParsingDescribe("文件解析成功");
                                 }
+                                parsingLogService.save(parsingLog);
                             }
                         }
                     }

+ 2 - 2
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/AccuracyCalculationServiceImpl.java

@@ -1271,7 +1271,7 @@ public class AccuracyCalculationServiceImpl extends ServiceImpl<AccuracyCalculat
             CalculationInfo calculationInfo = new CalculationInfo();
             // 如果是短期数据
             if ("short".equals(type)) {
-                List<ForecastPowerShortTermHis> shortFilter = forecastShortList.stream().filter(u -> u.getForecastTime().compareTo(getDateTimeOfTimestamp(finalTime)) == 0).collect(Collectors.toList());
+                List<ForecastPowerShortTermHis> shortFilter = forecastShortList.stream().filter(u -> u.getForecastTime().getTime()==finalTime).collect(Collectors.toList());
                 // 如果短期预测功率不为空且站场功率不为空
                 if (!shortFilter.isEmpty() && !pFilter.isEmpty()) {
                     // 短期预测功率
@@ -1313,7 +1313,7 @@ public class AccuracyCalculationServiceImpl extends ServiceImpl<AccuracyCalculat
                     }
                 } else {
                     // 获取该时间点超短期预测功率
-                    List<ForecastPowerUltraShortTermHis> ultraFilter = forecastUltraShortList.stream().filter(u -> u.getForecastTime().compareTo(getDateTimeOfTimestamp(finalTime)) == 0).collect(Collectors.toList());
+                    List<ForecastPowerUltraShortTermHis> ultraFilter = forecastUltraShortList.stream().filter(u -> u.getForecastTime().getTime()==finalTime).collect(Collectors.toList());
                     // 如果超短期预测功率不为空且站场功率不为空
                     if (!ultraFilter.isEmpty()) {
                         // 超短期预测功率

+ 3 - 3
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/PowerStationStatusDataServiceImpl.java

@@ -120,7 +120,7 @@ public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationS
                List<ForecastPowerShortTermHis> result = forecastPowerShortTermHisList.stream().filter(c -> c.getForecastManufactor().equals(fm[finalI])).collect(Collectors.toList());
                Map<Long, String> dqMap = new HashMap<>();
                for (ForecastPowerShortTermHis forecastPowerShortTermHis : result) {
-                   dqMap.put(forecastPowerShortTermHis.getForecastTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(), forecastPowerShortTermHis.getAbleValue().toString());
+                   dqMap.put(forecastPowerShortTermHis.getForecastTime().getTime(), forecastPowerShortTermHis.getAbleValue().toString());
                }
                List tempdqList = new ArrayList();
                for (Long tempDateTime = startDateTime; tempDateTime < endDateTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
@@ -157,7 +157,7 @@ public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationS
                List<ForecastPowerShortTerm> result = forecastPowerShortTermList.stream().filter(c -> c.getForecastManufactor().equals(fm[finalI])).collect(Collectors.toList());
                Map<Long, String> dqMap = new HashMap<>();
                for (ForecastPowerShortTerm forecastPowerShortTerm : result) {
-                   dqMap.put(forecastPowerShortTerm.getForecastTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(), forecastPowerShortTerm.getFpValue().toString());
+                   dqMap.put(forecastPowerShortTerm.getForecastTime().getTime(), forecastPowerShortTerm.getFpValue().toString());
                }
                List tempdqList = new ArrayList();
                for (Long tempDateTime = startDateTime; tempDateTime < endDateTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
@@ -196,7 +196,7 @@ public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationS
             List<ForecastPowerUltraShortTermHis> result = forecastPowerUltraShortTermHisList.stream().filter(c -> c.getForecastManufactor().equals(fm[finalI])).collect(Collectors.toList());
             Map<Long, String> cdqMap = new HashMap<>();
             for (ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis : result) {
-                cdqMap.put(forecastPowerUltraShortTermHis.getForecastTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(), forecastPowerUltraShortTermHis.getAbleValue().toString());
+                cdqMap.put(forecastPowerUltraShortTermHis.getForecastTime().getTime(), forecastPowerUltraShortTermHis.getAbleValue().toString());
             }
             List tempcdqList = new ArrayList();
             for (Long tempDateTime = startDateTime; tempDateTime < endDateTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {

+ 7 - 5
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingCdqInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jiayue.ipp.idp.service.impl.an;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -31,6 +32,7 @@ import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -77,7 +79,7 @@ public class ParsingCdqInfoServiceImpl extends ServiceImpl<ParsingCdqInfoMapper,
                     List<BigDecimal> bigDecimals = parsingFpValue(parsingCdqInfo.getFpValue(), fileContent);
 
                     if (!bigDecimals.isEmpty()) {
-                        LocalDate genDate = parsingGenDate(parsingCdqInfo.getGenDate(), fileContent);
+                        Date genDate = parsingGenDate(parsingCdqInfo.getGenDate(), fileContent);
                         Long forecastTime = parsingForecastTime(parsingCdqInfo.getForecastTime(), fileContent);
 
                         if (forecastTime != 0L) {
@@ -91,7 +93,7 @@ public class ParsingCdqInfoServiceImpl extends ServiceImpl<ParsingCdqInfoMapper,
                                 forecastPowerUltraShortTermHis.setGenDate(genDate);
                                 forecastPowerUltraShortTermHis.setStationCode(parsingUrl.getStationCode());
                                 forecastPowerUltraShortTermHis.setAbleValue(bigDecimal);
-                                LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(forecastTime), ZoneId.systemDefault());
+                                Date localDateTime = new Date(forecastTime);
                                 forecastPowerUltraShortTermHis.setForecastTime(localDateTime);
                                 forecastPowerUltraShortTermHis.setForecastHowLongAgo(ago);
                                 forecastPowerUltraShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
@@ -153,8 +155,8 @@ public class ParsingCdqInfoServiceImpl extends ServiceImpl<ParsingCdqInfoMapper,
 
 
     //目前所知该类型在文件中只有s一种形式,暂不支持m
-    protected LocalDate parsingGenDate(String sign, List<String> fileContent) {
-        LocalDate genDate = LocalDate.now();
+    protected Date parsingGenDate(String sign, List<String> fileContent) {
+        Date genDate = new Date();
         try {
             if (!sign.equals("")) {
                 FileParsingConfig config = FieldUtil.getConfig(sign);
@@ -171,7 +173,7 @@ public class ParsingCdqInfoServiceImpl extends ServiceImpl<ParsingCdqInfoMapper,
                     result = s.substring(startLength, startLength + length);
 
                     DateTimeFormatter fmt = DateTimeFormatter.ofPattern(config.getFormat());
-                    genDate = LocalDate.parse(result, fmt);
+                    genDate = DateUtil.parse(result, fmt.toString());
                     log.info("解析超短期【数据生成日期】成功,日期为:{}", result);
                 } else {
                     log.error("解析超短期【数据生成日期】时公式标识不存在所在行");

+ 82 - 73
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingDqInfoServiceImpl.java

@@ -1,8 +1,11 @@
 package com.jiayue.ipp.idp.service.impl.an;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTerm;
 import com.jiayue.ipp.common.data.entity.ForecastPowerShortTermHis;
 import com.jiayue.ipp.common.data.entity.an.ParsingDqInfo;
@@ -28,12 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.File;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -73,83 +74,91 @@ public class ParsingDqInfoServiceImpl extends ServiceImpl<ParsingDqInfoMapper, P
             if (!parsingDqInfos.isEmpty()) {
                 ParsingDqInfo parsingDqInfo = parsingDqInfos.get(0);
 
-                //判断文件名是否符合配置
-                if (file.getName().contains(parsingDqInfo.getFileName())) {
-
-                    List<String> fileContent = FileUtil.getFileContent(file);
-                    if (parsingDqInfo.getDataType().equals(FieldUtil.MULTI)) {
-                        List<BigDecimal> bigDecimals;
-                        if (parsingDqInfo.getFpValue() != null) ;
-                        bigDecimals = parsingFpValue(parsingDqInfo.getFpValue(), fileContent);
-
-                        if (bigDecimals.size() > 0) {
-
-                            LocalDate genDate = parsingGenDate(parsingDqInfo.getGenDate(), fileContent);
-                            Long forecastTime = parsingForecastTime(parsingDqInfo.getForecastTime(), fileContent);
-
-                            if (forecastTime != 0l) {
-                                int ago = -1;
-                                for (BigDecimal bigDecimal : bigDecimals) {
-                                    LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(forecastTime), ZoneId.systemDefault());
-                                    forecastTime += Constant.INTERVALTIME;
-                                    int n = ago / 96;
-                                    if (n > 0) {
-                                        ForecastPowerShortTermHis forecastPowerShortTermHis = new ForecastPowerShortTermHis();
-                                        forecastPowerShortTermHis.setGenDate(genDate);
-                                        forecastPowerShortTermHis.setStationCode(parsingUrl.getStationCode());
-                                        forecastPowerShortTermHis.setAbleValue(bigDecimal);
-                                        forecastPowerShortTermHis.setForecastTime(localDateTime);
-                                        forecastPowerShortTermHis.setForecastHowLongAgo(n);
-                                        forecastPowerShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
-                                        forecastPowerShortTermHisList.add(forecastPowerShortTermHis);
+                    //判断文件名是否符合配置
+                    if (file.getName().contains(parsingDqInfo.getFileName())) {
+
+                        List<String> fileContent = FileUtil.getFileContent(file);
+                        if (parsingDqInfo.getDataType().equals(FieldUtil.MULTI)) {
+                            List<BigDecimal> bigDecimals;
+                            if (parsingDqInfo.getFpValue() != null) ;
+                            bigDecimals = parsingFpValue(parsingDqInfo.getFpValue(), fileContent);
+
+                            if (bigDecimals.size() > 0) {
+
+                                LocalDate genDate = parsingGenDate(parsingDqInfo.getGenDate(), fileContent);
+                                Long forecastTime = parsingForecastTime(parsingDqInfo.getForecastTime(), fileContent);
+                                long secondDayTime = com.jiayue.ipp.idp.util.DateMomentUtil.getDayStartTime(System.currentTimeMillis())+1000*60*60*24;
+                                if (forecastTime==secondDayTime){
+                                    if (forecastTime != 0l) {
+                                        Long systemTime = System.currentTimeMillis();
+                                        for (BigDecimal bigDecimal : bigDecimals) {
+                                            Date forecastDate = new Date(forecastTime);
+                                            ForecastPowerShortTermHis forecastPowerShortTermHis = new ForecastPowerShortTermHis();
+                                            forecastPowerShortTermHis.setGenDate(genDate);
+                                            forecastPowerShortTermHis.setStationCode(parsingUrl.getStationCode());
+                                            forecastPowerShortTermHis.setAbleValue(bigDecimal);
+                                            forecastPowerShortTermHis.setForecastTime(forecastDate);
+                                            forecastPowerShortTermHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime,forecastTime));
+                                            forecastPowerShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
+                                            forecastPowerShortTermHisList.add(forecastPowerShortTermHis);
+
+                                            ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
+                                            forecastPowerShortTerm.setForecastTime(forecastDate);
+                                            forecastPowerShortTerm.setStationCode(parsingUrl.getStationCode());
+                                            forecastPowerShortTerm.setFpValue(bigDecimal);
+                                            forecastPowerShortTerm.setGenDate(forecastDate);
+                                            forecastPowerShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
+                                            forecastPowerShortTermList.add(forecastPowerShortTerm);
+
+                                            forecastTime += Constant.INTERVALTIME;
+                                        }
+
+                                        // 保存短期实时
+                                        Date startTime = forecastPowerShortTermList.get(0).getForecastTime();
+                                        Date endTime = forecastPowerShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime();
+                                        LambdaQueryWrapper<ForecastPowerShortTerm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                                        lambdaQueryWrapper.eq(ForecastPowerShortTerm::getStationCode, parsingUrl.getStationCode());
+                                        lambdaQueryWrapper.eq(ForecastPowerShortTerm::getForecastManufactor, parsingUrl.getForecastManufactor());
+                                        lambdaQueryWrapper.between(ForecastPowerShortTerm::getForecastTime, startTime, endTime);
+                                        forecastPowerShortTermService.remove(lambdaQueryWrapper);
+                                        forecastPowerShortTermService.saveBatch(forecastPowerShortTermList);
+
+                                        // 保存短期历史
+//                                        LocalDate today = LocalDate.now();
+                                        LambdaQueryWrapper<ForecastPowerShortTermHis> forecastPowerShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                                        forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getStationCode, parsingUrl.getStationCode());
+                                        forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getForecastManufactor, parsingUrl.getForecastManufactor());
+                                        forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getGenDate, DateUtil.format(new Date(),"yyyy-MM-dd"));
+                                        forecastPowerShortTermHisService.remove(forecastPowerShortTermHisLambdaQueryWrapper);
+                                        forecastPowerShortTermHisService.saveBatch(forecastPowerShortTermHisList);
+
+
+                                        log.info("解析DQ文件:{} 成功! O(∩_∩)O", file.getName());
+                                        parsingStatus = FileTypeEnum.DQ.name();
+                                    } else {
+                                        parsingStatus += "解析DQ文件时间错误";
+                                        log.error("解析DQ文件时间错误");
                                     }
-
-                                    ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
-                                    forecastPowerShortTerm.setForecastTime(localDateTime);
-                                    forecastPowerShortTerm.setStationCode(parsingUrl.getStationCode());
-                                    forecastPowerShortTerm.setFpValue(bigDecimal);
-                                    forecastPowerShortTerm.setGenDate(genDate);
-                                    forecastPowerShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
-                                    forecastPowerShortTermList.add(forecastPowerShortTerm);
-
-                                    ago++;
+                                }
+                                else{
+                                    parsingStatus += "dq文件里日期不对";
+                                    log.info("dq文件里日期不对");
                                 }
 
-
-                                LocalDate today = LocalDate.now();
-                                LambdaQueryWrapper<ForecastPowerShortTermHis> forecastPowerShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
-                                forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getStationCode, parsingUrl.getStationCode());
-                                forecastPowerShortTermHisLambdaQueryWrapper.between(ForecastPowerShortTermHis::getGenDate, today.atStartOfDay(), today);
-                                forecastPowerShortTermHisService.remove(forecastPowerShortTermHisLambdaQueryWrapper);
-                                forecastPowerShortTermHisService.saveBatch(forecastPowerShortTermHisList);
-
-
-                                LocalDateTime startTime = forecastPowerShortTermList.get(0).getForecastTime();
-                                LocalDateTime endTime = forecastPowerShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime();
-                                LambdaQueryWrapper<ForecastPowerShortTerm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-                                lambdaQueryWrapper.eq(ForecastPowerShortTerm::getStationCode, parsingUrl.getStationCode());
-                                lambdaQueryWrapper.between(ForecastPowerShortTerm::getForecastTime, startTime, endTime);
-                                forecastPowerShortTermService.remove(lambdaQueryWrapper);
-                                forecastPowerShortTermService.saveBatch(forecastPowerShortTermList);
-
-
-                                log.info("解析DQ文件:{} 成功! O(∩_∩)O", file.getName());
-                                parsingStatus = FileTypeEnum.DQ.name();
                             } else {
-                                parsingStatus += "解析DQ文件时间错误";
-                                log.error("解析DQ文件时间错误");
+                                parsingStatus += "解析短期文件无数据";
+                                log.error("解析短期文件无数据");
                             }
-
                         } else {
-                            parsingStatus += "解析短期文件无数据";
-                            log.error("解析短期文件无数据");
+                            parsingStatus += "dq暂无单行解析方式";
+                            log.info("dq暂无单行解析方式");
                         }
-                    } else {
-                        parsingStatus += "dq暂无单行解析方式";
-                        log.info("dq暂无单行解析方式");
                     }
-
-                }
+//                }
+//                else{
+//                    parsingStatus += "dq文件里日期不对";
+//                    log.info("dq文件里日期不对");
+//                }
             }
         } catch (Exception e) {
             parsingStatus += "解析短期数据失败";