Browse Source

解析功能初次提交,包括解析站端dq,cdq,cft,qxz,fj,nbq,rp,nwp,以及修改了部分表结构

tl 7 months ago
parent
commit
3eb194f4e5
52 changed files with 1224 additions and 1122 deletions
  1. 7 0
      cpp-admin/pom.xml
  2. 3 0
      cpp-admin/src/main/java/com/cpp/CppApplication.java
  3. 3 3
      cpp-admin/src/main/java/com/cpp/web/controller/configManager/InverterInfoController.java
  4. 3 7
      cpp-admin/src/main/java/com/cpp/web/domain/datafactory/ParsingLog.java
  5. 2 7
      cpp-admin/src/main/java/com/cpp/web/domain/datafactory/ParsingType.java
  6. 1 1
      cpp-admin/src/main/java/com/cpp/web/domain/datafactory/dto/ParsingResultDto.java
  7. 0 7
      cpp-admin/src/main/java/com/cpp/web/domain/station/InverterInfo.java
  8. 3 2
      cpp-admin/src/main/java/com/cpp/web/domain/station/InverterStatusData.java
  9. 2 1
      cpp-admin/src/main/java/com/cpp/web/domain/station/PowerStationStatusData.java
  10. 0 7
      cpp-admin/src/main/java/com/cpp/web/domain/station/WeatherStationInfo.java
  11. 1 1
      cpp-admin/src/main/java/com/cpp/web/domain/station/WeatherStationStatusData.java
  12. 0 7
      cpp-admin/src/main/java/com/cpp/web/domain/station/WindTowerInfo.java
  13. 1 1
      cpp-admin/src/main/java/com/cpp/web/domain/station/WindTowerStatusData.java
  14. 0 8
      cpp-admin/src/main/java/com/cpp/web/domain/station/WindTurbineInfo.java
  15. 1 1
      cpp-admin/src/main/java/com/cpp/web/domain/station/WindTurbineStatusData.java
  16. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerShortTermCloudMapper.java
  17. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerUltraShortTermCloudMapper.java
  18. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/cloud/NwpCloudMapper.java
  19. 17 0
      cpp-admin/src/main/java/com/cpp/web/mapper/datafactory/ParsingLogMapper.java
  20. 0 2
      cpp-admin/src/main/java/com/cpp/web/mapper/datafactory/ParsingTypeMapper.java
  21. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerShortTermStationMapper.java
  22. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerUltraShortTermStationMapper.java
  23. 1 1
      cpp-admin/src/main/java/com/cpp/web/mapper/station/NwpStationMapper.java
  24. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerShortTermCloudService.java
  25. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerUltraShortTermCloudService.java
  26. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/cloud/NwpCloudService.java
  27. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerShortTermCloudServiceImpl.java
  28. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerUltraShortTermCloudServiceImpl.java
  29. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/NwpCloudServiceImpl.java
  30. 110 23
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/FtpFileParsing.java
  31. 22 16
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/ParsingInterface.java
  32. 20 19
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/ParsingLogService.java
  33. 99 151
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingCdqServiceImpl.java
  34. 102 89
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingCftServiceImpl.java
  35. 95 160
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingDqServiceImpl.java
  36. 95 86
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingFjServiceImpl.java
  37. 37 34
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingLogServiceImpl.java
  38. 98 79
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingNbqServiceImpl.java
  39. 142 181
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingNwpServiceImpl.java
  40. 91 73
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingQxzServiceImpl.java
  41. 88 108
      cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingRpServiceImpl.java
  42. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerShortTermStationService.java
  43. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerUltraShortTermStationService.java
  44. 1 1
      cpp-admin/src/main/java/com/cpp/web/service/station/NwpStationService.java
  45. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerShortTermStationServiceImpl.java
  46. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerUltraShortTermStationServiceImpl.java
  47. 3 3
      cpp-admin/src/main/java/com/cpp/web/service/station/impl/NwpStationServiceImpl.java
  48. 8 13
      cpp-admin/src/main/java/com/cpp/web/service/station/impl/PowerStationStatusDataServiceImpl.java
  49. 3 3
      cpp-admin/src/main/java/com/cpp/web/utils/ParsingEfileUtil.java
  50. 1 1
      cpp-admin/src/main/java/com/cpp/web/utils/ParsingFieldUtil.java
  51. 138 0
      cpp-admin/src/main/java/com/cpp/web/utils/ParsingFileUtil.java
  52. 1 1
      cpp-admin/src/main/java/com/cpp/web/utils/ParsingUtil.java

+ 7 - 0
cpp-admin/pom.xml

@@ -68,6 +68,13 @@
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+
+        <!--        ftp-->
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <version>3.3</version>
+        </dependency>
     </dependencies>
     <profiles>    <!--考虑到window 和linux环境 npm命令格式的问题,使用maven的profile实现动态指定命令-->
         <profile>

+ 3 - 0
cpp-admin/src/main/java/com/cpp/CppApplication.java

@@ -3,12 +3,15 @@ package com.cpp;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 
 /**
  * 启动程序
  *
  * @author ruoyi
  */
+@EnableScheduling
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
 public class CppApplication
 {

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

@@ -117,11 +117,11 @@ public class InverterInfoController {
     @PostMapping("/findByStationCode")
     public R findByStationCode(String stationCode) {
         List<InverterInfo> inverterInfoList = inverterInfoService.findByStationCode(stationCode);
-        List<Map<String, String>> list = new ArrayList<>();
+        List<Map<String, Object>> list = new ArrayList<>();
         for (InverterInfo e : inverterInfoList) {
-            Map<String, String> map = new HashMap<>();
+            Map<String, Object> map = new HashMap<>();
             map.put("label", e.getName());
-            map.put("value", e.getEquipmentNo());
+            map.put("value", e.getId());
             list.add(map);
         }
         return R.ok(list);

+ 3 - 7
cpp-admin/src/main/java/com/cpp/web/domain/datafactory/ParsingLog.java

@@ -3,6 +3,7 @@ package com.cpp.web.domain.datafactory;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.cpp.common.annotation.Excel;
 import com.cpp.common.core.domain.BaseEntity;
+import com.cpp.web.domain.BaseCppEntity;
 import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
@@ -18,12 +19,7 @@ import java.util.Date;
 @TableName("cpp_parsing_log")
 @EqualsAndHashCode(callSuper = true)
 @ApiModel(value = "cpp_parsing_log")
-public class ParsingLog extends BaseEntity {
-
-    /**
-     * 主键ID
-     */
-    private String id;
+public class ParsingLog extends BaseCppEntity {
 
     /**
      * 文件名
@@ -34,7 +30,7 @@ public class ParsingLog extends BaseEntity {
     /**
      * 文件解析状态
      */
-    @Excel(name = "文件解析状态1成功0失败")
+    @Excel(name = "文件解析状态:成功/失败")
     private String parsingFileStatus;
 
     /**

+ 2 - 7
cpp-admin/src/main/java/com/cpp/web/domain/datafactory/ParsingType.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.cpp.common.annotation.Excel;
 import com.cpp.common.core.domain.BaseEntity;
+import com.cpp.web.domain.BaseCppEntity;
 import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -23,14 +24,8 @@ import lombok.EqualsAndHashCode;
 @TableName("cpp_parsing_type")
 @EqualsAndHashCode(callSuper = true)
 @ApiModel(value = "cpp_parsing_type")
-public class ParsingType extends BaseEntity {
+public class ParsingType extends BaseCppEntity {
 
-    /**
-     * 主键ID
-     */
-    @TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "主键ID")
-    private Long id;
 
     /**
      * 识别文件名标识

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/domain/datafactory/dto/ParsingResultDto.java

@@ -12,6 +12,6 @@ import lombok.Data;
 public class ParsingResultDto {
     private String fileType;
     private String fileName;
-    private String status;
+    private String status = "fail";
     private String message;
 }

+ 0 - 7
cpp-admin/src/main/java/com/cpp/web/domain/station/InverterInfo.java

@@ -77,13 +77,6 @@ public class InverterInfo extends BaseCppEntity {
 
 
     /**
-     * 设备编号
-     */
-    @ApiModelProperty(value = "设备编号")
-    private String equipmentNo;
-
-
-    /**
      * 是否组串式 1:是 0:不是
      */
     @ApiModelProperty(value = "是否组串式 1:是 0:不是")

+ 3 - 2
cpp-admin/src/main/java/com/cpp/web/domain/station/InverterStatusData.java

@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
 import javax.validation.constraints.Digits;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 /**
  * cpp_inverter_status_data
@@ -29,7 +30,7 @@ public class InverterStatusData extends BaseCppEntity {
      * 设备主键ID
      */
     @ApiModelProperty(value = "设备主键ID")
-    private String equipmentId;
+    private Long equipmentId;
 
 
     /**
@@ -43,7 +44,7 @@ public class InverterStatusData extends BaseCppEntity {
      * 时间
      */
     @ApiModelProperty(value = "时间")
-    private LocalDateTime time;
+    private Date time;
 
 
     /**

+ 2 - 1
cpp-admin/src/main/java/com/cpp/web/domain/station/PowerStationStatusData.java

@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
 import javax.validation.constraints.Digits;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.util.Date;
 
 /**
  * cpp_power_station_status_data
@@ -29,7 +30,7 @@ public class PowerStationStatusData extends BaseCppEntity {
      * 时间
      */
     @ApiModelProperty(value = "时间")
-    private LocalDateTime time;
+    private Date time;
 
 
     /**

+ 0 - 7
cpp-admin/src/main/java/com/cpp/web/domain/station/WeatherStationInfo.java

@@ -117,13 +117,6 @@ public class WeatherStationInfo extends BaseCppEntity {
 
 
     /**
-     * 设备编号
-     */
-    @ApiModelProperty(value = "设备编号")
-    private String equipmentNo;
-
-
-    /**
      * 绑定数据采集通道
      */
     @ApiModelProperty(value = "绑定数据采集通道")

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/domain/station/WeatherStationStatusData.java

@@ -29,7 +29,7 @@ public class WeatherStationStatusData extends BaseCppEntity {
      * 设备主键ID
      */
     @ApiModelProperty(value = "设备主键ID")
-    private String equipmentId;
+    private Long equipmentId;
 
 
     /**

+ 0 - 7
cpp-admin/src/main/java/com/cpp/web/domain/station/WindTowerInfo.java

@@ -117,13 +117,6 @@ public class WindTowerInfo extends BaseCppEntity {
 
 
     /**
-     * 设备编号
-     */
-    @ApiModelProperty(value = "设备编号")
-    private String equipmentNo;
-
-
-    /**
      * 测风塔是否样板机 1:是 0:否
      */
     @ApiModelProperty(value = "测风塔是否样板机 1:是 0:否")

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/domain/station/WindTowerStatusData.java

@@ -29,7 +29,7 @@ public class WindTowerStatusData extends BaseCppEntity {
      * 设备主键ID
      */
     @ApiModelProperty(value = "设备主键ID")
-    private String equipmentId;
+    private Long equipmentId;
 
 
     /**

+ 0 - 8
cpp-admin/src/main/java/com/cpp/web/domain/station/WindTurbineInfo.java

@@ -115,14 +115,6 @@ public class WindTurbineInfo extends BaseCppEntity {
     @ApiModelProperty(value = "入库时间间隔 单位 s")
     private Integer timeInterval;
 
-
-    /**
-     * 设备编号
-     */
-    @ApiModelProperty(value = "设备编号")
-    private String equipmentNo;
-
-
     /**
      * 风机等级
      */

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/domain/station/WindTurbineStatusData.java

@@ -29,7 +29,7 @@ public class WindTurbineStatusData extends BaseCppEntity {
      * 设备主键ID
      */
     @ApiModelProperty(value = "设备主键ID")
-    private String equipmentId;
+    private Long equipmentId;
 
 
     /**

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerShortTermMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerShortTermCloudMapper.java

@@ -11,5 +11,5 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface ForecastPowerShortTermMapper extends BaseMapper<ForecastPowerShortTermCloud> {
+public interface ForecastPowerShortTermCloudMapper extends BaseMapper<ForecastPowerShortTermCloud> {
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerUltraShortTermMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/cloud/ForecastPowerUltraShortTermCloudMapper.java

@@ -11,6 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface ForecastPowerUltraShortTermMapper extends BaseMapper<ForecastPowerUltraShortTermCloud> {
+public interface ForecastPowerUltraShortTermCloudMapper extends BaseMapper<ForecastPowerUltraShortTermCloud> {
 
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/cloud/NwpMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/cloud/NwpCloudMapper.java

@@ -11,6 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface NwpMapper extends BaseMapper<NwpCloud> {
+public interface NwpCloudMapper extends BaseMapper<NwpCloud> {
 
 }

+ 17 - 0
cpp-admin/src/main/java/com/cpp/web/mapper/datafactory/ParsingLogMapper.java

@@ -0,0 +1,17 @@
+package com.cpp.web.mapper.datafactory;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cpp.web.domain.datafactory.ParsingLog;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 解析配置mapper
+ *
+ * @author tl
+ * @date 2022-05-11 09:47:21
+ */
+@Mapper
+public interface ParsingLogMapper extends BaseMapper<ParsingLog> {
+
+}

+ 0 - 2
cpp-admin/src/main/java/com/cpp/web/mapper/datafactory/ParsingTypeMapper.java

@@ -18,6 +18,4 @@ import java.util.List;
 public interface ParsingTypeMapper extends BaseMapper<ParsingType> {
 
 
-    List<ParsingType> selectTypeList();
-
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerShortTermHisMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerShortTermStationMapper.java

@@ -10,6 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface ForecastPowerShortTermHisMapper extends BaseMapper<ForecastPowerShortTermStation> {
+public interface ForecastPowerShortTermStationMapper extends BaseMapper<ForecastPowerShortTermStation> {
 
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerUltraShortTermHisMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/station/ForecastPowerUltraShortTermStationMapper.java

@@ -10,6 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface ForecastPowerUltraShortTermHisMapper extends BaseMapper<ForecastPowerUltraShortTermStation> {
+public interface ForecastPowerUltraShortTermStationMapper extends BaseMapper<ForecastPowerUltraShortTermStation> {
 
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/mapper/station/NwpHisMapper.java → cpp-admin/src/main/java/com/cpp/web/mapper/station/NwpStationMapper.java

@@ -10,6 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @date 2024-09-23 15:28:33
  */
 @Mapper
-public interface NwpHisMapper extends BaseMapper<NwpStation> {
+public interface NwpStationMapper extends BaseMapper<NwpStation> {
 
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerShortTermService.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerShortTermCloudService.java

@@ -12,7 +12,7 @@ import java.util.List;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface ForecastPowerShortTermService extends IService<ForecastPowerShortTermCloud> {
+public interface ForecastPowerShortTermCloudService extends IService<ForecastPowerShortTermCloud> {
     /**
      * 根据场站编号和时间范围来查询
      *

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerUltraShortTermService.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/ForecastPowerUltraShortTermCloudService.java

@@ -12,7 +12,7 @@ import java.util.List;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface ForecastPowerUltraShortTermService extends IService<ForecastPowerUltraShortTermCloud> {
+public interface ForecastPowerUltraShortTermCloudService extends IService<ForecastPowerUltraShortTermCloud> {
 
     /**
      * 根据场站编号和时间范围来查询

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/cloud/NwpService.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/NwpCloudService.java

@@ -12,6 +12,6 @@ import java.util.Date;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface NwpService extends IService<NwpCloud> {
+public interface NwpCloudService extends IService<NwpCloud> {
     QueryWrapper<NwpCloud> getPageByStationCodeAndeTimeBetween(String stationCode, Date startTime, Date endTime, String forecastManufactor);
 }

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerShortTermServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerShortTermCloudServiceImpl.java

@@ -3,8 +3,8 @@ package com.cpp.web.service.cloud.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.cloud.ForecastPowerShortTermCloud;
-import com.cpp.web.mapper.cloud.ForecastPowerShortTermMapper;
-import com.cpp.web.service.cloud.ForecastPowerShortTermService;
+import com.cpp.web.mapper.cloud.ForecastPowerShortTermCloudMapper;
+import com.cpp.web.service.cloud.ForecastPowerShortTermCloudService;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -17,7 +17,7 @@ import java.util.List;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class ForecastPowerShortTermServiceImpl extends ServiceImpl<ForecastPowerShortTermMapper, ForecastPowerShortTermCloud> implements ForecastPowerShortTermService {
+public class ForecastPowerShortTermCloudServiceImpl extends ServiceImpl<ForecastPowerShortTermCloudMapper, ForecastPowerShortTermCloud> implements ForecastPowerShortTermCloudService {
 
 
     @Override

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerUltraShortTermServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/ForecastPowerUltraShortTermCloudServiceImpl.java

@@ -3,8 +3,8 @@ package com.cpp.web.service.cloud.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.cloud.ForecastPowerUltraShortTermCloud;
-import com.cpp.web.mapper.cloud.ForecastPowerUltraShortTermMapper;
-import com.cpp.web.service.cloud.ForecastPowerUltraShortTermService;
+import com.cpp.web.mapper.cloud.ForecastPowerUltraShortTermCloudMapper;
+import com.cpp.web.service.cloud.ForecastPowerUltraShortTermCloudService;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -17,7 +17,7 @@ import java.util.List;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class ForecastPowerUltraShortTermServiceImpl extends ServiceImpl<ForecastPowerUltraShortTermMapper, ForecastPowerUltraShortTermCloud> implements ForecastPowerUltraShortTermService {
+public class ForecastPowerUltraShortTermCloudServiceImpl extends ServiceImpl<ForecastPowerUltraShortTermCloudMapper, ForecastPowerUltraShortTermCloud> implements ForecastPowerUltraShortTermCloudService {
 
     @Override
     public List<ForecastPowerUltraShortTermCloud> findByStationCodeAndStartTimeAndEndTime(String stationCode, Date startTime, Date endTime) {

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/NwpServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/cloud/impl/NwpCloudServiceImpl.java

@@ -3,8 +3,8 @@ package com.cpp.web.service.cloud.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.cloud.NwpCloud;
-import com.cpp.web.mapper.cloud.NwpMapper;
-import com.cpp.web.service.cloud.NwpService;
+import com.cpp.web.mapper.cloud.NwpCloudMapper;
+import com.cpp.web.service.cloud.NwpCloudService;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -16,7 +16,7 @@ import java.util.Date;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class NwpServiceImpl extends ServiceImpl<NwpMapper, NwpCloud> implements NwpService {
+public class NwpCloudServiceImpl extends ServiceImpl<NwpCloudMapper, NwpCloud> implements NwpCloudService {
 
 
     @Override

+ 110 - 23
cpp-admin/src/main/java/com/cpp/web/service/datafactory/FtpFileParsing.java

@@ -1,20 +1,34 @@
 package com.cpp.web.service.datafactory;
 
+import cn.hutool.core.lang.Filter;
 import cn.hutool.extra.ftp.Ftp;
 import cn.hutool.extra.ftp.FtpConfig;
 import cn.hutool.extra.ftp.FtpMode;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cpp.web.domain.datafactory.ParsingFileUrl;
+import com.cpp.web.domain.datafactory.ParsingLog;
 import com.cpp.web.domain.datafactory.ParsingType;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.datafactory.enums.ParsingDataSourcesEnum;
+import com.cpp.web.mapper.datafactory.ParsingFileUrlMapper;
+import com.cpp.web.mapper.datafactory.ParsingLogMapper;
 import com.cpp.web.mapper.datafactory.ParsingTypeMapper;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.net.ftp.FTPFile;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Properties;
+import java.text.DateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * ftp文件解析
@@ -29,40 +43,115 @@ public class FtpFileParsing {
 
     private final ParsingTypeMapper parsingTypeMapper;
 
+    private final Map<String, ParsingInterface> parsingInterfaceMap;
+
+    private final ParsingFileUrlService parsingFileUrlService;
+
+    private final ParsingLogService parsingLogService;
+
+    private final String PARSING_FILE_TEMP_DIR = "/";
+    private final String PARSING_FILE_SUCCESS_DIR = "/";
+    private final String PARSING_FILE_FAIL_DIR = "/";
+
+    private final File fileTempDir = new File(PARSING_FILE_TEMP_DIR);
+
     /**
      * 解析文件方法
+     * 逻辑:先配置识别文件名称类型:识别文件名称关键字对应的文件类型
+     * 有文件类型的配置才可以进入下一步
+     * <p>
+     * 查找各场站配置的ftp目录,去下载文件并识别文件类型执行对应的解析策略
+     *
+     * 必要条件:1.配置文件识别类型。2.配置下载路径。3.配置解析公式
      *
-     * @param parsingFileUrls 解析文件路径
+     * @param
      * @return
      */
-    public void parsingFile(List<ParsingFileUrl> parsingFileUrls) {
+    @Scheduled(fixedRate = 300000L)
+    public void parsingFile() {
 
-        List<ParsingType> parsingTypes = parsingTypeMapper.selectTypeList();
+        List<ParsingType> parsingTypes = parsingTypeMapper.selectList(null);
 
         if (parsingTypes.size() > 0) {
-            Ftp ftp = createParsingFtp();
-            if (ftp != null) {
-                for (ParsingFileUrl parsingFileUrl : parsingFileUrls) {
-                    String url = parsingFileUrl.getUrl();
-                    if (ftp.existFile(url)) {
-                        List<String> fileNames = ftp.ls(url);
-                        for (String fileName : fileNames) {
-                            for (ParsingType parsingType : parsingTypes) {
-                                if (fileName.contains(parsingType.getFileName())){
 
+            List<ParsingFileUrl> fileUrls = parsingFileUrlService.list(Wrappers.lambdaQuery(ParsingFileUrl.class).eq(ParsingFileUrl::getParsingDataSources, ParsingDataSourcesEnum.E1));
+
+            if (fileUrls.size() > 0) {
+                Map<FileTypeEnum, List<ParsingFileUrl>> fileTypeEnumListMap = fileUrls.stream().collect(Collectors.groupingBy(ParsingFileUrl::getFileType, Collectors.toList()));
+
+                Ftp ftp = createParsingFtp();
+                if (ftp != null) {
+                    List<ParsingLog> parsingLogs = new ArrayList<>();
+                    for (ParsingType parsingType : parsingTypes) {
+                        if (fileTypeEnumListMap.containsKey(parsingType.getFileType())) {
+                            ParsingInterface parsingInterface = parsingInterfaceMap.get(parsingType.getFileType().name() + "Parsing");
+                            parsingInterface.activationParsingConf();//初始化解析配置
+                            List<ParsingFileUrl> fileUrlList = fileTypeEnumListMap.get(parsingType.getFileType());
+                            for (ParsingFileUrl parsingFileUrl : fileUrlList) {
+
+                                String ftpUrl = parsingFileUrl.getUrl();
+                                List<String> fileNames = ftp.ls(ftpUrl).stream().filter(f -> f.contains(parsingType.getFileName())).collect(Collectors.toList());
+                                if (fileNames.size() > 0) {
+                                    for (String fileName : fileNames) {
+                                        //下载文件到临时目录
+                                        ftp.download(ftpUrl, fileName, fileTempDir);
+                                        File file = FileUtils.getFile(fileTempDir, fileName);
+                                        ParsingLog parsingLog = new ParsingLog();
+                                        Date now = new Date();
+                                        parsingLog.setParsingTime(now);
+                                        ParsingResultDto parsingResultDto = parsingInterface.parsing(file, parsingFileUrl.getStationCode());
+                                        parsingLog.setParsingDescribe(parsingResultDto.getMessage());
+                                        parsingLog.setFileType(parsingType.getFileType());
+                                        if (parsingResultDto.getStatus().equals("fail")) {
+                                            try {
+                                                File failFileDir = new File(PARSING_FILE_FAIL_DIR + File.separator + DateFormatUtils.format(now, "yyyy-MM-DD"));
+                                                File failFile = new File(failFileDir.getPath() + File.separator + fileName);
+                                                if (failFile.exists()) {
+                                                    failFile.delete();
+                                                    log.error("已有过解析失败文件,错误文件将覆盖!场站编号:{},文件名称:{}", parsingFileUrl.getStationCode(), fileName);
+                                                }
+
+                                                FileUtils.moveFile(file, failFileDir);
+                                            } catch (IOException e) {
+                                                log.error("解析文件失败后文件移动失败!场站编号:{},文件名称:{}", parsingFileUrl.getStationCode(), fileName, e);
+                                                e.printStackTrace();
+                                            }
+                                            file.delete();//失败删除本地文件,等待下次下载
+                                            parsingLog.setParsingFileStatus("失败");
+                                        } else {
+                                            ftp.delFile(ftpUrl + "/" + fileName);//成功删除ftp上的文件
+
+                                            try {
+                                                File successFileDir = new File(PARSING_FILE_SUCCESS_DIR + File.separator + DateFormatUtils.format(now, "yyyy-MM-DD"));
+                                                File successFile = new File(successFileDir.getPath() + File.separator + fileName);
+                                                if (successFile.exists()) {
+                                                    successFile.delete();
+                                                    log.error("已有过解析成功文件,成功文件将覆盖!场站编号:{},文件名称:{}", parsingFileUrl.getStationCode(), fileName);
+                                                }
+
+                                                FileUtils.moveFile(file, successFileDir);
+                                            } catch (IOException e) {
+                                                log.error("解析文件成功后文件移动失败!场站编号:{},文件名称:{}", parsingFileUrl.getStationCode(), fileName, e);
+                                                e.printStackTrace();
+                                            }
+                                            file.delete();//失败删除本地文件,等待下次下载
+                                            parsingLog.setParsingFileStatus("成功");
+                                        }
+                                        parsingLogs.add(parsingLog);
+                                    }
                                 }
                             }
                         }
-                    } else {
-                        log.info("ftp服务端,场站:{},无对应路径,{}", parsingFileUrl.getStationCode(), parsingFileUrl.getUrl());
                     }
-                }
 
-                try {
-                    ftp.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
+                    try {
+                        ftp.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    parsingLogService.saveBatch(parsingLogs);
                 }
+
             }
         } else {
             log.info("未配置文件识别类型标识,无法进行下载解析");
@@ -107,6 +196,4 @@ public class FtpFileParsing {
     }
 
 
-
-
 }

+ 22 - 16
cpp-admin/src/main/java/com/cpp/web/service/datafactory/ParsingInterface.java

@@ -2,16 +2,20 @@ package com.cpp.web.service.datafactory;
 
 
 import com.cpp.web.domain.datafactory.BaseParsing;
+import com.cpp.web.domain.datafactory.ParsingCdq;
 import com.cpp.web.domain.datafactory.dto.ParsingConfParam;
-import com.cpp.web.utils.FieldUtil;
-import com.cpp.web.utils.PUtil;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingUtil;
 
+import java.io.File;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 /**
- * 解析业务层总接口
+ * 解析站端数据总接口
  *
  * @author tl
  * @date 2022-05-11 09:51:21
@@ -22,13 +26,16 @@ public interface ParsingInterface {
 
     boolean deleteById(Long id);
 
-//    FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl);
+    ParsingResultDto parsing(File file, String stationCode);
 
+    boolean activationParsingConf();
 
-    default Long parsingTime(String sign, List<String> fileContent) {
-        Long time = 0l;
+    List selectByStationCode(String stationCode);
+
+    default Date parsingTime(String sign, List<String> fileContent) {
+        Date time = null;
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
             String s = fileContent.get(Integer.parseInt(config.getLineNumber()) - 1);
             int signIndex = s.indexOf(config.getDataSign());
             String result;
@@ -42,7 +49,7 @@ public interface ParsingInterface {
 
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(config.getFormat());
 
-                time = simpleDateFormat.parse(result).getTime();
+                time = simpleDateFormat.parse(result);
             }
 
         } catch (RuntimeException e) {
@@ -59,11 +66,11 @@ public interface ParsingInterface {
         BigDecimal value = new BigDecimal(-99);
         try {
             if (sign != null && !sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
+                ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
                 String s = fileContent.get(Integer.parseInt(config.getLineNumber()) - 1);
 
-                String[] strings = PUtil.splitLineWithSpace(s);
+                String[] strings = ParsingUtil.splitLineWithSpace(s);
                 int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
                 String result = strings[rowNumber];
                 value = new BigDecimal(result);
@@ -79,12 +86,12 @@ public interface ParsingInterface {
     default String parsingStatus(String sign, List<String> fileContent) {
         String status = null;
         try {
-            if (sign != null&&!sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
+            if (sign != null && !sign.equals("")) {
+                ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
                 String s = fileContent.get(Integer.parseInt(config.getLineNumber()) - 1);
 
-                String[] strings = PUtil.splitLineWithSpace(s);
+                String[] strings = ParsingUtil.splitLineWithSpace(s);
                 int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
                 status = strings[rowNumber];
             }
@@ -101,11 +108,11 @@ public interface ParsingInterface {
         String name = "";
         try {
             if (sign != null && !sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
+                ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
                 String s = fileContent.get(Integer.parseInt(config.getLineNumber()) - 1);
 
-                String[] strings = PUtil.splitLineWithSpace(s);
+                String[] strings = ParsingUtil.splitLineWithSpace(s);
                 int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
                 name = strings[rowNumber];
             }
@@ -117,5 +124,4 @@ public interface ParsingInterface {
     }
 
 
-
 }

+ 20 - 19
cpp-admin/src/main/java/com/cpp/web/service/datafactory/ParsingLogService.java

@@ -1,19 +1,20 @@
-//package com.cpp.web.service.datafactory;
-//
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.baomidou.mybatisplus.extension.service.IService;
-//import com.jiayue.ipp.common.data.entity.an.ParsingLog;
-//
-//import java.util.Date;
-//
-///**
-// * 解析记录业务层接口
-// *
-// * @author tl
-// * @date 2022-05-16 11:15:21
-// */
-//public interface ParsingLogService extends IService<ParsingLog> {
-//
-//    QueryWrapper<ParsingLog> getByStationCodeAndCreateTimeAndFileStatusAndFileType(String stationCode, Date startTime, Date endTime, String fileStatus, String fileType);
-//
-//}
+package com.cpp.web.service.datafactory;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cpp.web.domain.datafactory.ParsingLog;
+
+import java.util.Date;
+
+/**
+ * 解析记录业务层接口
+ *
+ * @author tl
+ * @date 2022-05-16 11:15:21
+ */
+public interface ParsingLogService extends IService<ParsingLog> {
+
+    QueryWrapper<ParsingLog> getByStationCodeAndCreateTimeAndFileStatusAndFileType(String stationCode, Date startTime, Date endTime, String fileStatus, String fileType);
+
+}

+ 99 - 151
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingCdqServiceImpl.java

@@ -4,15 +4,20 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingCdq;
+import com.cpp.web.domain.datafactory.ParsingDq;
 import com.cpp.web.domain.datafactory.dto.ParsingConfParam;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
 import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.ForecastPowerShortTermStation;
+import com.cpp.web.domain.station.ForecastPowerUltraShortTermStation;
 import com.cpp.web.mapper.datafactory.ParsingCdqMapper;
-import com.cpp.web.service.cloud.ForecastPowerUltraShortTermService;
+import com.cpp.web.service.cloud.ForecastPowerUltraShortTermCloudService;
 import com.cpp.web.service.datafactory.ParsingCdqService;
 import com.cpp.web.service.datafactory.ParsingInterface;
-import com.cpp.web.service.station.ForecastPowerUltraShortTermHisService;
-import com.cpp.web.utils.FieldUtil;
-import com.cpp.web.utils.PUtil;
+import com.cpp.web.service.station.ForecastPowerUltraShortTermStationService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
+import com.cpp.web.utils.ParsingUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -25,6 +30,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 超短期解析业务层实现类
@@ -32,17 +38,15 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("cdqParsing")
 @AllArgsConstructor
 @Slf4j
 @Transactional
 public class ParsingCdqServiceImpl extends ServiceImpl<ParsingCdqMapper, ParsingCdq> implements ParsingCdqService, ParsingInterface {
 
-//    private final Long intervalTime = 900000l;
+    private final ForecastPowerUltraShortTermStationService forecastPowerUltraShortTermStationService;
 
-    private final ForecastPowerUltraShortTermHisService forecastPowerUltraShortTermHisService;
-
-    private final ForecastPowerUltraShortTermService forecastPowerUltraShortTermService;
+    private List<ParsingCdq> parsingCdqs = new ArrayList<>();
 
     @Override
     public boolean save(BaseParsing parsingInfo) {
@@ -53,156 +57,84 @@ public class ParsingCdqServiceImpl extends ServiceImpl<ParsingCdqMapper, Parsing
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.CDQ.getCode()+"");
-////
-////        String parsingStatus = ParsingConstant.FAIL;
-//
-//        try {
-//            // 查询ParsingCdqInfo列表
-//            List<ParsingCdqInfo> parsingCdqInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingCdqInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            if (!parsingCdqInfos.isEmpty()) {
-//                ParsingCdqInfo parsingCdqInfo = parsingCdqInfos.get(0);
-//
-//                if (file.getName().contains(parsingCdqInfo.getFileName())) {
-//
-//                    List<String> fileContent = FileUtil.getFileContent(file);
-//                    if (parsingCdqInfo.getDataType().equals(FieldUtil.MULTI)) {
-//                        List<BigDecimal> bigDecimals;
-//                        if (parsingCdqInfo.getFpValue() != null) ;
-//                        bigDecimals = parsingFpValue(parsingCdqInfo.getFpValue(), fileContent);
-//
-//                        if (bigDecimals.size() > 0) {
-//                            Long forecastTime = parsingForecastTime(parsingCdqInfo.getForecastTime(), fileContent);
-//                            if (forecastTime != 0L) {
-//                                // 所属产生时刻用第一个点位减去15分钟
-//                                long genDate = forecastTime-1000*60*15L;
-//
-//                                int ago = 1;
-//                                List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = new ArrayList<>();
-//                                List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
-//
-//                                for (BigDecimal bigDecimal : bigDecimals) {
-//                                    // 构造ForecastPowerUltraShortTermHis对象
-//                                    ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis = new ForecastPowerUltraShortTermHis();
-//                                    forecastPowerUltraShortTermHis.setGenDate(new Date(genDate));
-//                                    forecastPowerUltraShortTermHis.setStationCode(parsingUrl.getStationCode());
-//                                    forecastPowerUltraShortTermHis.setAbleValue(bigDecimal);
-//                                    Date localDateTime = new Date(forecastTime);
-//                                    forecastPowerUltraShortTermHis.setForecastTime(localDateTime);
-//                                    forecastPowerUltraShortTermHis.setForecastHowLongAgo(ago);
-//                                    forecastPowerUltraShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
-//                                    forecastTime += Constant.INTERVALTIME;
-//
-//                                    // 构造ForecastPowerUltraShortTerm对象
-//                                    ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
-//                                    forecastPowerUltraShortTerm.setForecastTime(localDateTime);
-//                                    forecastPowerUltraShortTerm.setStationCode(parsingUrl.getStationCode());
-//                                    forecastPowerUltraShortTerm.setFpValue(bigDecimal);
-//                                    forecastPowerUltraShortTerm.setGenDate(new Date(genDate));
-//                                    forecastPowerUltraShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
-//                                    forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
-//
-//                                    forecastPowerUltraShortTermHisList.add(forecastPowerUltraShortTermHis);
-//                                    ago++;
-//                                }
-//
-//                                fileAnalysisStatusDto.setStatus("1");
-//                                log.info("解析CDQ文件:{} 成功! O(∩_∩)O", file.getName());
-//
-//                                // 删除之前的ForecastPowerUltraShortTerm记录
-//                                LambdaQueryWrapper<ForecastPowerUltraShortTerm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-//                                lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getStationCode, parsingUrl.getStationCode());
-//                                lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getForecastManufactor, parsingUrl.getForecastManufactor());
-//                                lambdaQueryWrapper.between(ForecastPowerUltraShortTerm::getForecastTime, forecastPowerUltraShortTermList.get(0).getForecastTime(), forecastPowerUltraShortTermList.get(forecastPowerUltraShortTermList.size() - 1).getForecastTime());
-//                                forecastPowerUltraShortTermService.remove(lambdaQueryWrapper);
-//                                // 批量保存新的ForecastPowerUltraShortTerm记录
-//                                forecastPowerUltraShortTermService.saveBatch(forecastPowerUltraShortTermList);
-//
-//                                // 删除当天的ForecastPowerUltraShortTermHis记录
-//                                LambdaQueryWrapper<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
-//                                forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getGenDate, new Date(genDate));
-//                                forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getStationCode, parsingUrl.getStationCode());
-//                                forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getForecastManufactor, parsingUrl.getForecastManufactor());
-//                                forecastPowerUltraShortTermHisService.remove(forecastPowerUltraShortTermHisLambdaQueryWrapper);
-//                                // 批量保存新的ForecastPowerUltraShortTermHis记录
-//                                forecastPowerUltraShortTermHisService.saveBatch(forecastPowerUltraShortTermHisList);
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("解析超短期文件时间错误");
-//                                log.error("解析CDQ文件时间错误");
-//                            }
-//                        }
-//                        else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("解析超短期文件无数据");
-//                            log.error("解析超短期文件无数据");
-//                        }
-//
-//                    }else {
-//                        fileAnalysisStatusDto.setStatus("0");
-//                        fileAnalysisStatusDto.setMessage("超短期暂无单行解析方式");
-//                        log.info("cdq暂无单行解析方式");
-//                    }
-//                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析超短期数据失败!");
-//            log.error("解析超短期数据失败", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
-
-
-    //目前所知该类型在文件中只有s一种形式,暂不支持m
-    protected Date parsingGenDate(String sign, List<String> fileContent) {
-        Date genDate = new Date();
+
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.cdq.name());
+
         try {
-            if (!sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
-                String s = fileContent.get(PUtil.noParseInt(config.getLineNumber()));
-                int signIndex = s.indexOf(config.getDataSign());
-                String result;
-                if (signIndex > 0) {
-
-                    int startLength = config.getDataSign().length() + signIndex + 1;
-                    int length = config.getFormat().length();
-                    if (String.valueOf(s.charAt(startLength + 1)).equals("'")) {
-                        startLength += 1;
+            List<ForecastPowerUltraShortTermStation> forecastPowerUltraShortTermStationList = new ArrayList();
+
+            List<ParsingCdq> parsingCdqList = selectByStationCode(stationCode);
+
+            if (!parsingCdqList.isEmpty()) {
+                ParsingCdq parsingCdq = parsingCdqList.get(0);
+                List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                if (parsingCdq.getDataType().equals(ParsingFieldUtil.MULTI)) {//多行操作
+                    Date forecastTime = parsingForecastTime(parsingCdq.getForecastTime(), fileContent);
+                    Date time = forecastTime;
+                    if (forecastTime != null) {//解析时间成功才可以进行以下操作
+                        if (parsingCdq.getFpValue() != null) {
+                            List<BigDecimal> fpValues = parsingFpValue(parsingCdq.getFpValue(), fileContent);
+                            if (fpValues.size() > 0) {
+                                for (BigDecimal fpValue : fpValues) {
+                                    ForecastPowerUltraShortTermStation forecastPowerUltraShortTermStation = new ForecastPowerUltraShortTermStation();
+                                    forecastPowerUltraShortTermStation.setStationCode(stationCode);
+                                    forecastPowerUltraShortTermStation.setFpValue(fpValue);
+                                    forecastPowerUltraShortTermStation.setTime(time);
+                                    forecastPowerUltraShortTermStation.setForecastHowLongAgo(calcHowLongAgo(forecastTime, time));
+                                    forecastPowerUltraShortTermStationList.add(forecastPowerUltraShortTermStation);
+                                    time = new Date(time.getTime() + 900000L);//递增15分钟
+                                }
+                                forecastPowerUltraShortTermStationService.saveBatch(forecastPowerUltraShortTermStationList);
+                                log.info("解析DQ文件:{} 成功! O(∩_∩)O", file.getName());
+                                parsingResultDto.setStatus("success");
+                            } else {
+                                parsingResultDto.setMessage("解析短期文件时间错误");
+                                log.error("解析DQ文件时间错误");
+                            }
+                        } else {
+                            parsingResultDto.setMessage("短期文件里日期不对");
+                            log.error("dq文件里日期不对");
+                        }
+
+                    } else {
+                        parsingResultDto.setMessage("解析短期文件无数据");
+                        log.error("解析短期文件无数据");
                     }
-                    result = s.substring(startLength, startLength + length);
 
-                    DateTimeFormatter fmt = DateTimeFormatter.ofPattern(config.getFormat());
-                    genDate = DateUtil.parse(result, fmt.toString());
-                    log.info("解析超短期【数据生成日期】成功,日期为:{}", result);
-                } else {
-                    log.error("解析超短期【数据生成日期】时公式标识不存在所在行");
                 }
 
-            }
 
-        } catch (RuntimeException e) {
-            log.error("解析超短期【数据生成日期】失败");
-            e.printStackTrace();
+            } else {
+                parsingResultDto.setMessage("短期暂无单行解析方式");
+                log.error("dq暂无单行解析方式");
+            }
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析短期数据失败!");
+            log.error("解析短期数据失败! /(ㄒoㄒ)/~~", e);
         } finally {
-            return genDate;
+            return parsingResultDto;
         }
     }
 
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingCdqs = baseMapper.selectList(null);
+        return true;
+    }
+
 
     //解析预测时间
-    protected Long parsingForecastTime(String sign, List<String> fileContent) {
-        Long forecastTime = 0l;
+    protected Date parsingForecastTime(String sign, List<String> fileContent) {
+        Date forecastTime = null;
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
-            String s = fileContent.get(PUtil.noParseInt(config.getLineNumber()));
+            String s = fileContent.get(ParsingUtil.noParseInt(config.getLineNumber()));
             int signIndex = s.indexOf(config.getDataSign());
             String result;
             if (signIndex > 0) {
@@ -215,7 +147,7 @@ public class ParsingCdqServiceImpl extends ServiceImpl<ParsingCdqMapper, Parsing
 
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(config.getFormat());
 
-                forecastTime = simpleDateFormat.parse(result).getTime();
+                forecastTime = simpleDateFormat.parse(result);
 
                 log.info("解析超短期【预测时间】成功,开始时间为:{}", result);
             } else {
@@ -247,16 +179,16 @@ public class ParsingCdqServiceImpl extends ServiceImpl<ParsingCdqMapper, Parsing
     protected List<BigDecimal> parsingFpValue(String sign, List<String> fileContent) {
         List<BigDecimal> fpValues = new ArrayList<>();
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
 
             String[] lineNumber = config.getLineNumber().split("-");
-            int startLine = PUtil.noParseInt(lineNumber[0]);
-            int endLine = PUtil.noParseInt(lineNumber[1]);
+            int startLine = ParsingUtil.noParseInt(lineNumber[0]);
+            int endLine = ParsingUtil.noParseInt(lineNumber[1]);
 
             for (int i = startLine; i <= endLine; i++) {
-                String[] strings = PUtil.splitLineWithSpace(fileContent.get(i));
-                String result = strings[PUtil.noParseInt(config.getRowNumber())];
+                String[] strings = ParsingUtil.splitLineWithSpace(fileContent.get(i));
+                String result = strings[ParsingUtil.noParseInt(config.getRowNumber())];
 
                 fpValues.add(new BigDecimal(result));
             }
@@ -271,5 +203,21 @@ public class ParsingCdqServiceImpl extends ServiceImpl<ParsingCdqMapper, Parsing
         }
     }
 
+    /**
+     * 计算D+x中的x
+     *
+     * @param baseTime
+     * @param time
+     */
+    public Integer calcHowLongAgo(Date baseTime, Date time) {
+        return ((int) (time.getTime() - baseTime.getTime() % 900000L)) + 1;
+    }
+
+
+
+    public List<ParsingCdq> selectByStationCode(String stationCode) {
+        return this.parsingCdqs.stream().filter(p -> p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
+
 
 }

+ 102 - 89
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingCftServiceImpl.java

@@ -1,23 +1,30 @@
 package com.cpp.web.service.datafactory.impl;
 
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingCft;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.WindTowerInfo;
+import com.cpp.web.domain.station.WindTowerStatusData;
 import com.cpp.web.mapper.datafactory.ParsingCftMapper;
 import com.cpp.web.service.datafactory.ParsingCftService;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.station.WindTowerInfoService;
 import com.cpp.web.service.station.WindTowerStatusDataService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 测风塔解析业务层实现类
@@ -25,14 +32,16 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("cftParsing")
 @AllArgsConstructor
 @Slf4j
 @Transactional
 public class ParsingCftServiceImpl extends ServiceImpl<ParsingCftMapper, ParsingCft> implements ParsingCftService, ParsingInterface {
 
 
-    private final Long intervalTime = 300000L;
+    private List<ParsingCft> parsingCfts = new ArrayList<>();
+
+    private List<WindTowerInfo> windTowerInfos = new ArrayList<>();
 
     private final WindTowerStatusDataService windTowerStatusDataService;
 
@@ -48,90 +57,94 @@ public class ParsingCftServiceImpl extends ServiceImpl<ParsingCftMapper, Parsing
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.CFT.getCode()+"");
-//
-//        try {
-//            List<ParsingCftInfo> parsingCftInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingCftInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            if (parsingCftInfos.size() > 0) {
-//                List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list(Wrappers.lambdaQuery(WindTowerInfo.class)
-//                        .eq(WindTowerInfo::getStationCode, parsingUrl.getStationCode()));
-//                if (windTowerInfoList.size() > 0) {
-//                    List<String> fileContent = FileUtil.getFileContent(file);
-//                    for (ParsingCftInfo parsingCftInfo : parsingCftInfos) {
-//                        //判断文件名是否符合配置
-//                        if (file.getName().indexOf(parsingCftInfo.getFileName()) >= 0) {
-//
-//                            if (parsingCftInfo.getDataType().equals(FieldUtil.SINGLE)) {
-//                                Long time = parsingTime(parsingCftInfo.getTime(), fileContent);
-//                                if (time != 0L) {
-//                                    WindTowerStatusData windTowerStatusData = new WindTowerStatusData();
-//                                    windTowerStatusData.setTime(new Date(time));
-//
-//                                    windTowerStatusData.setTInst(parsingValue(parsingCftInfo.gettInst(), fileContent));
-//                                    windTowerStatusData.setPaInst(parsingValue(parsingCftInfo.getPaInst(), fileContent));
-//                                    windTowerStatusData.setRhInst(parsingValue(parsingCftInfo.getRhInst(), fileContent));
-//                                    windTowerStatusData.setAirDensity(parsingValue(parsingCftInfo.getAirDensity(), fileContent));
-//
-//                                    windTowerStatusData.setWsInst10(parsingValue(parsingCftInfo.getWsInst10(), fileContent));
-//                                    windTowerStatusData.setWsInst30(parsingValue(parsingCftInfo.getWsInst30(), fileContent));
-//                                    windTowerStatusData.setWsInst50(parsingValue(parsingCftInfo.getWsInst50(), fileContent));
-//                                    windTowerStatusData.setWsInst60(parsingValue(parsingCftInfo.getWsInst60(), fileContent));
-//                                    windTowerStatusData.setWsInst70(parsingValue(parsingCftInfo.getWsInst70(), fileContent));
-//                                    windTowerStatusData.setWsInst80(parsingValue(parsingCftInfo.getWsInst80(), fileContent));
-//                                    windTowerStatusData.setWsInst90(parsingValue(parsingCftInfo.getWsInst90(), fileContent));
-//                                    windTowerStatusData.setWsInst100(parsingValue(parsingCftInfo.getWsInst100(), fileContent));
-//                                    windTowerStatusData.setWsInst110(parsingValue(parsingCftInfo.getWsInst110(), fileContent));
-//                                    windTowerStatusData.setWsInstHubHeight(parsingValue(parsingCftInfo.getWsInstHubHeight(), fileContent));
-//
-//                                    windTowerStatusData.setWdInst10(parsingValue(parsingCftInfo.getWdInst10(), fileContent));
-//                                    windTowerStatusData.setWdInst30(parsingValue(parsingCftInfo.getWdInst30(), fileContent));
-//                                    windTowerStatusData.setWdInst50(parsingValue(parsingCftInfo.getWdInst50(), fileContent));
-//                                    windTowerStatusData.setWdInst60(parsingValue(parsingCftInfo.getWdInst60(), fileContent));
-//                                    windTowerStatusData.setWdInst70(parsingValue(parsingCftInfo.getWdInst70(), fileContent));
-//                                    windTowerStatusData.setWdInst80(parsingValue(parsingCftInfo.getWdInst80(), fileContent));
-//                                    windTowerStatusData.setWdInst90(parsingValue(parsingCftInfo.getWdInst90(), fileContent));
-//                                    windTowerStatusData.setWdInst100(parsingValue(parsingCftInfo.getWdInst100(), fileContent));
-//                                    windTowerStatusData.setWdInst110(parsingValue(parsingCftInfo.getWdInst110(), fileContent));
-//                                    windTowerStatusData.setWdInstHubHeight(parsingValue(parsingCftInfo.getWdInstHubHeight(), fileContent));
-//
-//                                    windTowerStatusData.setStatus(parsingStatus(parsingCftInfo.getStatus(), fileContent));
-//                                    windTowerStatusData.setStationCode(parsingUrl.getStationCode());
-//
-//                                    windTowerStatusData.setEquipmentId(windTowerInfoList.get(0).getEquipmentNo());
-//
-//                                    windTowerStatusDataService.save(windTowerStatusData);
-//                                    fileAnalysisStatusDto.setStatus("1");
-//                                    log.info("解析CFT文件:{} 成功! O(∩_∩)O", file.getName());
-//                                } else {
-//                                    fileAnalysisStatusDto.setStatus("0");
-//                                    fileAnalysisStatusDto.setMessage("解析测风塔文件时间错误");
-//                                    log.error("解析CFT文件时间错误");
-//                                }
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("测风塔暂无多行解析方式");
-//                                log.info("cft暂无多行解析方式");
-//                            }
-//                        }
-//                    }
-//                } else {
-//                    fileAnalysisStatusDto.setStatus("0");
-//                    fileAnalysisStatusDto.setMessage("测风塔未配置作为解析使用设备");
-//                    log.info("cft未配置作为解析使用设备");
-//                }
-//
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析测风塔数据失败!");
-//            log.error("解析测风塔数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
+
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+        {
+            ParsingResultDto parsingResultDto = new ParsingResultDto();
+            parsingResultDto.setFileName(file.getName());
+            parsingResultDto.setFileType(FileTypeEnum.cft.name());
+
+            try {
+                List<ParsingCft> parsingCfts = selectByStationCode(stationCode);
+                if (!parsingCfts.isEmpty()) {
+                    List<WindTowerInfo> windTowerInfoList = this.windTowerInfos.stream().filter(w -> w.getStationCode().equals(stationCode)).collect(Collectors.toList());
+                    ParsingCft parsingCft = parsingCfts.get(0);
+                    if (windTowerInfoList.size() > 0) {
+                        Long eqId = windTowerInfoList.get(0).getId();//通常每个场站只上报一个测风塔数据,所有配置多个的情况下只取第一个存储
+                        List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                            //判断文件名是否符合配置
+                            if (parsingCft.getDataType().equals(ParsingFieldUtil.SINGLE)) {
+                                Date time = parsingTime(parsingCft.getTime(), fileContent);
+                                if (time != null) {
+                                    WindTowerStatusData windTowerStatusData = new WindTowerStatusData();
+                                    windTowerStatusData.setTime(time);
+                                    windTowerStatusData.setTInst(parsingValue(parsingCft.gettInst(), fileContent));
+                                    windTowerStatusData.setPaInst(parsingValue(parsingCft.getPaInst(), fileContent));
+                                    windTowerStatusData.setRhInst(parsingValue(parsingCft.getRhInst(), fileContent));
+                                    windTowerStatusData.setAirDensity(parsingValue(parsingCft.getAirDensity(), fileContent));
+
+                                    windTowerStatusData.setWsInst10(parsingValue(parsingCft.getWsInst10(), fileContent));
+                                    windTowerStatusData.setWsInst30(parsingValue(parsingCft.getWsInst30(), fileContent));
+                                    windTowerStatusData.setWsInst50(parsingValue(parsingCft.getWsInst50(), fileContent));
+                                    windTowerStatusData.setWsInst60(parsingValue(parsingCft.getWsInst60(), fileContent));
+                                    windTowerStatusData.setWsInst70(parsingValue(parsingCft.getWsInst70(), fileContent));
+                                    windTowerStatusData.setWsInst80(parsingValue(parsingCft.getWsInst80(), fileContent));
+                                    windTowerStatusData.setWsInst90(parsingValue(parsingCft.getWsInst90(), fileContent));
+                                    windTowerStatusData.setWsInst100(parsingValue(parsingCft.getWsInst100(), fileContent));
+                                    windTowerStatusData.setWsInst110(parsingValue(parsingCft.getWsInst110(), fileContent));
+                                    windTowerStatusData.setWsInstHubHeight(parsingValue(parsingCft.getWsInstHubHeight(), fileContent));
+
+                                    windTowerStatusData.setWdInst10(parsingValue(parsingCft.getWdInst10(), fileContent));
+                                    windTowerStatusData.setWdInst30(parsingValue(parsingCft.getWdInst30(), fileContent));
+                                    windTowerStatusData.setWdInst50(parsingValue(parsingCft.getWdInst50(), fileContent));
+                                    windTowerStatusData.setWdInst60(parsingValue(parsingCft.getWdInst60(), fileContent));
+                                    windTowerStatusData.setWdInst70(parsingValue(parsingCft.getWdInst70(), fileContent));
+                                    windTowerStatusData.setWdInst80(parsingValue(parsingCft.getWdInst80(), fileContent));
+                                    windTowerStatusData.setWdInst90(parsingValue(parsingCft.getWdInst90(), fileContent));
+                                    windTowerStatusData.setWdInst100(parsingValue(parsingCft.getWdInst100(), fileContent));
+                                    windTowerStatusData.setWdInst110(parsingValue(parsingCft.getWdInst110(), fileContent));
+                                    windTowerStatusData.setWdInstHubHeight(parsingValue(parsingCft.getWdInstHubHeight(), fileContent));
+
+                                    windTowerStatusData.setStatus(parsingStatus(parsingCft.getStatus(), fileContent));
+                                    windTowerStatusData.setStationCode(parsingCft.getStationCode());
+
+                                    windTowerStatusData.setEquipmentId(eqId);
+
+                                    windTowerStatusDataService.save(windTowerStatusData);
+                                    parsingResultDto.setStatus("success");
+                                    log.info("解析CFT文件:{} 成功! O(∩_∩)O", file.getName());
+                                } else {
+                                    parsingResultDto.setMessage("解析测风塔文件时间错误");
+                                    log.error("解析CFT文件时间错误");
+                                }
+                            } else {
+                                parsingResultDto.setMessage("测风塔暂无多行解析方式");
+                                log.error("cft暂无多行解析方式");
+                            }
+
+                        }
+
+                }
+            } catch (Exception e) {
+                parsingResultDto.setMessage("解析测风塔数据失败!");
+                log.error("解析测风塔数据失败! /(ㄒoㄒ)/~~", e);
+            } finally {
+                return parsingResultDto;
+            }
+        }
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingCfts = baseMapper.selectList(null);
+        this.windTowerInfos = windTowerInfoService.list(null);
+        return false;
+    }
+
+
+    @Override
+    public List<ParsingCft> selectByStationCode(String stationCode) {
+        return this.parsingCfts.stream().filter(p -> p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
 }

+ 95 - 160
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingDqServiceImpl.java

@@ -1,19 +1,19 @@
 package com.cpp.web.service.datafactory.impl;
 
-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.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingDq;
 import com.cpp.web.domain.datafactory.dto.ParsingConfParam;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.ForecastPowerShortTermStation;
 import com.cpp.web.mapper.datafactory.ParsingDqMapper;
-import com.cpp.web.service.cloud.ForecastPowerShortTermService;
 import com.cpp.web.service.datafactory.ParsingDqService;
 import com.cpp.web.service.datafactory.ParsingInterface;
-import com.cpp.web.service.station.ForecastPowerShortTermHisService;
-import com.cpp.web.utils.FieldUtil;
-import com.cpp.web.utils.PUtil;
+import com.cpp.web.service.station.ForecastPowerShortTermStationService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
+import com.cpp.web.utils.ParsingUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -22,11 +22,10 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.File;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 短期解析业务层实现类
@@ -34,15 +33,16 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("dqParsing")
 @Slf4j
 @AllArgsConstructor
 @Transactional
 public class ParsingDqServiceImpl extends ServiceImpl<ParsingDqMapper, ParsingDq> implements ParsingDqService, ParsingInterface {
 
-    private final ForecastPowerShortTermHisService forecastPowerShortTermHisService;
 
-    private final ForecastPowerShortTermService forecastPowerShortTermService;
+    private List<ParsingDq> parsingDqs = new ArrayList<>();
+
+    private final ForecastPowerShortTermStationService forecastPowerShortTermStationService;
 
     @Override
     public boolean save(BaseParsing parsingInfo) {
@@ -53,159 +53,80 @@ public class ParsingDqServiceImpl extends ServiceImpl<ParsingDqMapper, ParsingDq
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.DQ.getCode()+"");
-//
-//        try {
-//            List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = new ArrayList<>();
-//            List<ForecastPowerShortTerm> forecastPowerShortTermList = new ArrayList<>();
-//            List<ParsingDqInfo> parsingDqInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingDqInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            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);
-//                                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(new Date());
-//                                            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(new Date());
-//                                            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());
-//                                        fileAnalysisStatusDto.setStatus("1");
-//                                    } else {
-//                                        fileAnalysisStatusDto.setStatus("0");
-//                                        fileAnalysisStatusDto.setMessage("解析短期文件时间错误");
-//                                        log.error("解析DQ文件时间错误");
-//                                    }
-//                                }
-//                                else{
-//                                    fileAnalysisStatusDto.setStatus("0");
-//                                    fileAnalysisStatusDto.setMessage("短期文件里日期不对");
-//                                    log.info("dq文件里日期不对");
-//                                }
-//
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("解析短期文件无数据");
-//                                log.error("解析短期文件无数据");
-//                            }
-//                        } else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("短期暂无单行解析方式");
-//                            log.info("dq暂无单行解析方式");
-//                        }
-//                    }
-////                }
-////                else{
-////                    parsingStatus += "dq文件里日期不对";
-////                    log.info("dq文件里日期不对");
-////                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析短期数据失败!");
-//            log.error("解析短期数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
-
-
-    //目前所知该类型在文件中只有s一种形式==》暂不支持m
-    protected LocalDate parsingGenDate(String sign, List<String> fileContent) {
-        LocalDate genDate = LocalDate.now();
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingDqs = baseMapper.selectList(null);
+        return true;
+    }
+
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileType(FileTypeEnum.dq.name());
+        parsingResultDto.setFileName(file.getName());
 
         try {
-            if (!sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
-
-                String s = fileContent.get(PUtil.noParseInt(config.getLineNumber()));
-                int signIndex = s.indexOf(config.getDataSign());
-                String result;
-                if (signIndex > 0) {
-                    int startLength = config.getDataSign().length() + signIndex + 1;
-                    int length = config.getFormat().length();
-                    if (String.valueOf(s.charAt(startLength + 1)).equals("'")) {
-                        startLength += 1;
+            List<ForecastPowerShortTermStation> forecastPowerShortTermStationList = new ArrayList();
+
+            List<ParsingDq> parsingDqList = selectByStationCode(stationCode);
+
+            if (!parsingDqList.isEmpty()) {
+                ParsingDq parsingDqInfo = parsingDqList.get(0);
+                List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                if (parsingDqInfo.getDataType().equals(ParsingFieldUtil.MULTI)) {//多行操作
+                    Date forecastTime = parsingForecastTime(parsingDqInfo.getForecastTime(), fileContent);
+                    Date time = forecastTime;
+                    if (forecastTime != null) {//解析时间成功才可以进行以下操作
+                        if (parsingDqInfo.getFpValue() != null) {
+                            List<BigDecimal> fpValues = parsingFpValue(parsingDqInfo.getFpValue(), fileContent);
+                            if (fpValues.size() > 0) {
+                                for (BigDecimal fpValue : fpValues) {
+                                    ForecastPowerShortTermStation forecastPowerShortTermStation = new ForecastPowerShortTermStation();
+                                    forecastPowerShortTermStation.setStationCode(stationCode);
+                                    forecastPowerShortTermStation.setFpValue(fpValue);
+                                    forecastPowerShortTermStation.setTime(time);
+                                    forecastPowerShortTermStation.setForecastHowLongAgo(calcHowLongAgo(forecastTime, time));
+                                    forecastPowerShortTermStationList.add(forecastPowerShortTermStation);
+                                    time = new Date(time.getTime() + 900000L);//递增15分钟
+                                }
+                                forecastPowerShortTermStationService.saveBatch(forecastPowerShortTermStationList);
+                                log.info("解析DQ文件:{} 成功! O(∩_∩)O", file.getName());
+                                parsingResultDto.setStatus("success");
+                            } else {
+                                parsingResultDto.setMessage("解析短期文件时间错误");
+                                log.error("解析DQ文件时间错误");
+                            }
+                        } else {
+                            parsingResultDto.setMessage("短期文件里日期不对");
+                            log.error("dq文件里日期不对");
+                        }
+
+                    } else {
+                        parsingResultDto.setMessage("解析短期文件无数据");
+                        log.error("解析短期文件无数据");
                     }
-                    result = s.substring(startLength, startLength + length);
 
-                    DateTimeFormatter fmt = DateTimeFormatter.ofPattern(config.getFormat());
-                    genDate = LocalDate.parse(result, fmt);
-                    log.info("解析短期【数据生成日期】成功==》日期为:{}", result);
-                } else {
-                    log.error("解析短期【数据生成日期】时公式标识不存在所在行");
                 }
+
+
+            } else {
+                parsingResultDto.setMessage("短期暂无单行解析方式");
+                log.info("dq暂无单行解析方式");
             }
-        } catch (RuntimeException e) {
-            log.error("解析短期【数据生成日期】失败");
-            e.printStackTrace();
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析短期数据失败!");
+            log.error("解析短期数据失败! /(ㄒoㄒ)/~~", e);
         } finally {
-            return genDate;
+            return parsingResultDto;
         }
     }
 
-    protected Long parsingForecastTime(String sign, List<String> fileContent) {
-        Long forecastTime = 0l;
+    protected Date parsingForecastTime(String sign, List<String> fileContent) {
+        Date forecastTime = null;
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
-            String s = fileContent.get(PUtil.noParseInt(config.getLineNumber()));
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
+            String s = fileContent.get(ParsingUtil.noParseInt(config.getLineNumber()));
             int signIndex = s.indexOf(config.getDataSign());
             String result;
             if (signIndex > 0) {
@@ -218,7 +139,7 @@ public class ParsingDqServiceImpl extends ServiceImpl<ParsingDqMapper, ParsingDq
 
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(config.getFormat());
 
-                forecastTime = simpleDateFormat.parse(result).getTime();
+                forecastTime = simpleDateFormat.parse(result);
 
                 log.info("解析短期【预测时间】成功==》开始时间为:{}", result);
             } else {
@@ -249,16 +170,16 @@ public class ParsingDqServiceImpl extends ServiceImpl<ParsingDqMapper, ParsingDq
     protected List<BigDecimal> parsingFpValue(String sign, List<String> fileContent) {
         List<BigDecimal> fpValues = new ArrayList<>();
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
 
 
             String[] lineNumber = config.getLineNumber().split("-");
-            int startLine = PUtil.noParseInt(lineNumber[0]);
-            int endLine = PUtil.noParseInt(lineNumber[1]);
+            int startLine = ParsingUtil.noParseInt(lineNumber[0]);
+            int endLine = ParsingUtil.noParseInt(lineNumber[1]);
 
             for (int i = startLine; i <= endLine; i++) {
-                String[] strings = PUtil.splitLineWithSpace(fileContent.get(i));
-                String result = strings[PUtil.noParseInt(config.getRowNumber())];
+                String[] strings = ParsingUtil.splitLineWithSpace(fileContent.get(i));
+                String result = strings[ParsingUtil.noParseInt(config.getRowNumber())];
 
                 fpValues.add(new BigDecimal(result));
             }
@@ -272,4 +193,18 @@ public class ParsingDqServiceImpl extends ServiceImpl<ParsingDqMapper, ParsingDq
         }
     }
 
+    public List<ParsingDq> selectByStationCode(String stationCode) {
+        return this.parsingDqs.stream().filter(p -> p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
+
+
+    /**
+     * 计算D+x中的x
+     *
+     * @param baseTime
+     * @param time
+     */
+    public Integer calcHowLongAgo(Date baseTime, Date time) {
+        return ((int) (time.getTime() - baseTime.getTime() % 86400000L)) + 1;
+    }
 }

+ 95 - 86
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingFjServiceImpl.java

@@ -4,17 +4,24 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingFj;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.WindTurbineInfo;
+import com.cpp.web.domain.station.WindTurbineStatusData;
 import com.cpp.web.mapper.datafactory.ParsingFjMapper;
 import com.cpp.web.service.datafactory.ParsingFjService;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.station.WindTurbineInfoService;
 import com.cpp.web.service.station.WindTurbineStatusDataService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -25,19 +32,19 @@ import java.util.stream.Collectors;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("fjParsing")
 @AllArgsConstructor
 @Slf4j
 @Transactional
 public class ParsingFjServiceImpl extends ServiceImpl<ParsingFjMapper, ParsingFj> implements ParsingFjService, ParsingInterface {
 
-
-    private final Long intervalTime = 300000l;
-
     private final WindTurbineStatusDataService windTurbineStatusDataService;
 
     private final WindTurbineInfoService windTurbineInfoService;
 
+    private List<WindTurbineInfo> windTurbineInfos = new ArrayList<>();
+
+    private List<ParsingFj> parsingFjs = new ArrayList<>();
 
     @Override
     public boolean save(BaseParsing parsingInfo) {
@@ -48,88 +55,90 @@ public class ParsingFjServiceImpl extends ServiceImpl<ParsingFjMapper, ParsingFj
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl ftpParsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.FJ.getCode()+"");
-//
-//        try {
-//
-//
-//            List<ParsingFjInfo> parsingFjInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingFjInfo.class).like(ParsingInfo::getStationCode, ftpParsingUrl.getStationCode()));
-//            if (parsingFjInfos.size() > 0) {
-//
-//                List<String> fileContent = FileUtil.getFileContent(file);
-//                List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.list(Wrappers.lambdaQuery(WindTurbineInfo.class).eq(WindTurbineInfo::getStationCode, ftpParsingUrl.getStationCode()));
-//
-//                for (ParsingFjInfo parsingFjInfo : parsingFjInfos) {
-//                    //判断文件名是否符合配置
-//                    if (file.getName().indexOf(parsingFjInfo.getFileName()) >= 0) {
-//
-//                        WindTurbineStatusData windTurbineStatusData = new WindTurbineStatusData();
-//
-//                        if (parsingFjInfo.getDataType().equals(FieldUtil.SINGLE)) {
-//
-//                            String fjName = parsingName(parsingFjInfo.getEquipmentName(), fileContent);
-//
-//                            List<WindTurbineInfo> filterWindTurbineInfos = windTurbineInfoList.stream().filter(i -> i.getName().equals(fjName)).collect(Collectors.toList());
-//
-//                            if (filterWindTurbineInfos.size() > 0) {
-//                                windTurbineStatusData.setEquipmentId(filterWindTurbineInfos.get(0).getEquipmentNo());
-//                                Long time = parsingTime(parsingFjInfo.getTime(), fileContent);
-//                                if (time != 0l) {
-//                                    windTurbineStatusData.setTime(new Date(time));
-//
-//                                    windTurbineStatusData.setActivePower(parsingValue(parsingFjInfo.getActivePower(), fileContent));
-//                                    windTurbineStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingFjInfo.getCumulativeGeneratedEnergy(), fileContent));
-//                                    windTurbineStatusData.setDayGridConnectedHours(parsingValue(parsingFjInfo.getDayGridConnectedHours(), fileContent));
-//                                    windTurbineStatusData.setWindWheelRatedSpeed(parsingValue(parsingFjInfo.getWindWheelRatedSpeed(), fileContent));
-//                                    windTurbineStatusData.setDayElectricQuantity(parsingValue(parsingFjInfo.getDayElectricQuantity(), fileContent));
-//                                    windTurbineStatusData.setElectricalCurrent(parsingValue(parsingFjInfo.getElectricalCurrent(), fileContent));
-//                                    windTurbineStatusData.setPitchAngle(parsingValue(parsingFjInfo.getPitchAngle(), fileContent));
-//                                    windTurbineStatusData.setPowerFactor(parsingValue(parsingFjInfo.getPowerFactor(), fileContent));
-//                                    windTurbineStatusData.setReactivePower(parsingValue(parsingFjInfo.getReactivePower(), fileContent));
-//                                    windTurbineStatusData.setVoltage(parsingValue(parsingFjInfo.getVoltage(), fileContent));
-//                                    windTurbineStatusData.setWd(parsingValue(parsingFjInfo.getWd(), fileContent));
-//                                    windTurbineStatusData.setWs(parsingValue(parsingFjInfo.getWs(), fileContent));
-//                                    windTurbineStatusData.setT(parsingValue(parsingFjInfo.getT(), fileContent));
-//
-//                                    windTurbineStatusData.setStatus(parsingStatus(parsingFjInfo.getStatus(), fileContent));
-//                                    windTurbineStatusData.setStationCode(parsingFjInfo.getStationCode());
-//
-//                                    windTurbineStatusDataService.save(windTurbineStatusData);
-//                                    log.info("解析FJ文件:" + file.getName() + " 成功! O(∩_∩)O");
-//                                    fileAnalysisStatusDto.setStatus("1");
-//                                } else {
-//                                    fileAnalysisStatusDto.setStatus("0");
-//                                    fileAnalysisStatusDto.setMessage("解析风机文件时间错误");
-//                                    log.error("解析FJ文件时间错误");
-//                                }
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("风机在本地无配置无法解析");
-//                                log.info("fj {} 在本地无配置无法解析", fjName);
-//                            }
-//                        } else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("风机暂无多行解析方式");
-//                            log.info("fj暂无多行解析方式");
-//                        }
-//                    }
-//                }
-//            }
-//
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析风机数据错误!");
-//            log.error("解析风机数据错误",e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//
-//    }
 
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.fj.name());
+
+        try {
+
+
+            List<ParsingFj> parsingFjInfos = selectByStationCode(stationCode);
+            if (parsingFjInfos.size() > 0) {
+
+                List<String> fileContent = ParsingFileUtil.getFileContent(file);
+
+                for (ParsingFj parsingFjInfo : parsingFjInfos) {
+                    if (parsingFjInfo.getDataType().equals(ParsingFieldUtil.SINGLE)) {
+
+                        String fjName = parsingName(parsingFjInfo.getEquipmentName(), fileContent);
+
+                        List<WindTurbineInfo> filterWindTurbineInfos = windTurbineInfos.stream().filter(i -> i.getName().equals(fjName)).collect(Collectors.toList());
+
+                        if (filterWindTurbineInfos.size() > 0) {
+                            Long eqId = filterWindTurbineInfos.get(0).getId();
+
+                            Date time = parsingTime(parsingFjInfo.getTime(), fileContent);
+                            if (time != null) {
+                                WindTurbineStatusData windTurbineStatusData = new WindTurbineStatusData();
+                                windTurbineStatusData.setTime(time);
+                                windTurbineStatusData.setEquipmentId(eqId);
+                                windTurbineStatusData.setActivePower(parsingValue(parsingFjInfo.getActivePower(), fileContent));
+                                windTurbineStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingFjInfo.getCumulativeGeneratedEnergy(), fileContent));
+                                windTurbineStatusData.setDayGridConnectedHours(parsingValue(parsingFjInfo.getDayGridConnectedHours(), fileContent));
+                                windTurbineStatusData.setWindWheelRatedSpeed(parsingValue(parsingFjInfo.getWindWheelRatedSpeed(), fileContent));
+                                windTurbineStatusData.setDayElectricQuantity(parsingValue(parsingFjInfo.getDayElectricQuantity(), fileContent));
+                                windTurbineStatusData.setElectricalCurrent(parsingValue(parsingFjInfo.getElectricalCurrent(), fileContent));
+                                windTurbineStatusData.setPitchAngle(parsingValue(parsingFjInfo.getPitchAngle(), fileContent));
+                                windTurbineStatusData.setPowerFactor(parsingValue(parsingFjInfo.getPowerFactor(), fileContent));
+                                windTurbineStatusData.setReactivePower(parsingValue(parsingFjInfo.getReactivePower(), fileContent));
+                                windTurbineStatusData.setVoltage(parsingValue(parsingFjInfo.getVoltage(), fileContent));
+                                windTurbineStatusData.setWd(parsingValue(parsingFjInfo.getWd(), fileContent));
+                                windTurbineStatusData.setWs(parsingValue(parsingFjInfo.getWs(), fileContent));
+                                windTurbineStatusData.setT(parsingValue(parsingFjInfo.getT(), fileContent));
+
+                                windTurbineStatusData.setStatus(parsingStatus(parsingFjInfo.getStatus(), fileContent));
+                                windTurbineStatusData.setStationCode(parsingFjInfo.getStationCode());
+
+                                windTurbineStatusDataService.save(windTurbineStatusData);
+                                log.info("解析FJ文件:" + file.getName() + " 成功! O(∩_∩)O");
+                                parsingResultDto.setStatus("success");
+                            } else {
+                                parsingResultDto.setMessage("解析风机文件时间错误");
+                                log.error("解析FJ文件时间错误");
+                            }
+                        } else {
+                            parsingResultDto.setMessage("风机在本地无配置无法解析");
+                            log.error("fj {} 在本地无配置无法解析", fjName);
+                        }
+                    } else {
+                        parsingResultDto.setMessage("风机暂无多行解析方式");
+                        log.error("fj暂无多行解析方式");
+                    }
+
+                }
+            }
+
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析风机数据错误!");
+            log.error("解析风机数据错误", e);
+        } finally {
+            return parsingResultDto;
+        }
+
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingFjs = baseMapper.selectList(null);
+        this.windTurbineInfos = windTurbineInfoService.list();
+        return false;
+    }
 
+    @Override
+    public List selectByStationCode(String stationCode) {
+        return parsingFjs.stream().filter(p -> p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
 }

+ 37 - 34
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingLogServiceImpl.java

@@ -1,34 +1,37 @@
-//package com.cpp.web.service.datafactory.impl;
-//
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-//import org.springframework.stereotype.Service;
-//
-//import java.util.Date;
-//
-///**
-// * 解析记录业务层实现类
-// *
-// * @author tl
-// * @date 2022-05-11 18:07:03
-// */
-//@Service
-//public class ParsingLogServiceImpl extends ServiceImpl<ParsingLogMapper, ParsingLog> implements ParsingLogService {
-//    @Override
-//    public QueryWrapper<ParsingLog> getByStationCodeAndCreateTimeAndFileStatusAndFileType(String stationCode, Date startTime, Date endTime, String fileStatus, String fileType) {
-//        QueryWrapper<ParsingLog> wrapper = new QueryWrapper<>();
-//        if (stationCode != null && !stationCode.equals("")) {
-//            wrapper.eq("station_code", stationCode);
-//        }
-//        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
-//            wrapper.between("cpp_parsing_time", startTime, endTime);
-//        }
-//        if (fileStatus != null && !fileStatus.equals("")) {
-//            wrapper.eq("cpp_parsing_file_status", fileStatus);
-//        }
-//        if (fileType != null && !fileType.equals("")) {
-//            wrapper.eq("file_type", fileType);
-//        }
-//        return wrapper;
-//    }
-//}
+package com.cpp.web.service.datafactory.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cpp.web.domain.datafactory.ParsingLog;
+import com.cpp.web.mapper.datafactory.ParsingLogMapper;
+import com.cpp.web.service.datafactory.ParsingLogService;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * 解析记录业务层实现类
+ *
+ * @author tl
+ * @date 2022-05-11 18:07:03
+ */
+@Service
+public class ParsingLogServiceImpl extends ServiceImpl<ParsingLogMapper, ParsingLog> implements ParsingLogService {
+    @Override
+    public QueryWrapper<ParsingLog> getByStationCodeAndCreateTimeAndFileStatusAndFileType(String stationCode, Date startTime, Date endTime, String fileStatus, String fileType) {
+        QueryWrapper<ParsingLog> wrapper = new QueryWrapper<>();
+        if (stationCode != null && !stationCode.equals("")) {
+            wrapper.eq("station_code", stationCode);
+        }
+        if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
+            wrapper.between("cpp_parsing_time", startTime, endTime);
+        }
+        if (fileStatus != null && !fileStatus.equals("")) {
+            wrapper.eq("cpp_parsing_file_status", fileStatus);
+        }
+        if (fileType != null && !fileType.equals("")) {
+            wrapper.eq("file_type", fileType);
+        }
+        return wrapper;
+    }
+}

+ 98 - 79
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingNbqServiceImpl.java

@@ -4,11 +4,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingNbq;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.InverterInfo;
+import com.cpp.web.domain.station.InverterStatusData;
 import com.cpp.web.mapper.datafactory.ParsingNbqMapper;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.datafactory.ParsingNbqService;
 import com.cpp.web.service.station.InverterInfoService;
 import com.cpp.web.service.station.InverterStatusDataService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -18,6 +24,8 @@ import java.io.File;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -27,7 +35,7 @@ import java.util.stream.Collectors;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("nbqParsing")
 @AllArgsConstructor
 @Slf4j
 @Transactional
@@ -37,6 +45,10 @@ public class ParsingNbqServiceImpl extends ServiceImpl<ParsingNbqMapper, Parsing
 
     private final InverterInfoService inverterInfoService;
 
+    private List<ParsingNbq> parsingNbqs = new ArrayList<>();
+
+    private List<InverterInfo> inverterInfos = new ArrayList<>();
+
     @Override
     public boolean save(BaseParsing parsingInfo) {
         return save((ParsingNbq) parsingInfo);
@@ -47,82 +59,89 @@ public class ParsingNbqServiceImpl extends ServiceImpl<ParsingNbqMapper, Parsing
         return removeById(id);
     }
 
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl ftpParsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.NBQ.getCode()+"");
-//
-//        try {
-//
-//            //查询符合该场站的nbq配置信息
-//            List<ParsingNbqInfo> parsingNbqInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingNbqInfo.class).like(ParsingInfo::getStationCode, ftpParsingUrl.getStationCode()));
-//            if (parsingNbqInfos.size() > 0) {
-//
-//                //解析文件内容以行为单位的 List<String>
-//                List<String> fileContent = FileUtil.getFileContent(file);
-//
-//                //查询对应该场站路径下的逆变器信息
-//                List<InverterInfo> inverterInfoList = inverterInfoService.list(Wrappers.lambdaQuery(InverterInfo.class).eq(InverterInfo::getStationCode, ftpParsingUrl.getStationCode()));
-//
-//                //因为有可能该场站有多种解析配置,例如多个逆变器数据情况,需要循环解析信息
-//                for (ParsingNbqInfo parsingNbqInfo : parsingNbqInfos) {
-//                    //判断文件名是否符合配置
-//                    if (file.getName().indexOf(parsingNbqInfo.getFileName()) >= 0) {
-//
-//                        //判断数据类型是单行还是多行
-//                        if (parsingNbqInfo.getDataType().equals(FieldUtil.SINGLE)) {
-//                            /**
-//                             * 逆变器和风机id  需要解析名称找出对应设备存入id
-//                             *
-//                             */
-//                            String nbqName = parsingName(parsingNbqInfo.getEquipmentName(), fileContent);
-//                            List<InverterInfo> filterInverterInfos = inverterInfoList.stream().filter(i -> i.getName().equals(nbqName)).collect(Collectors.toList());
-//                            if (filterInverterInfos.size() > 0) {
-//                                Long time = parsingTime(parsingNbqInfo.getTime(), fileContent);
-//                                if (time != 0l) {
-//                                    InverterStatusData inverterStatusData = new InverterStatusData();
-//                                    LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
-//                                    inverterStatusData.setTime(localDateTime);
-//
-//                                    inverterStatusData.setActivePower(parsingValue(parsingNbqInfo.getActivePower(), fileContent));
-//                                    inverterStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingNbqInfo.getCumulativeGeneratedEnergy(), fileContent));
-//                                    inverterStatusData.setDayGridConnectedHours(parsingValue(parsingNbqInfo.getDayGridConnectedHours(), fileContent));
-//                                    inverterStatusData.setDayElectricQuantity(parsingValue(parsingNbqInfo.getDayElectricQuantity(), fileContent));
-//                                    inverterStatusData.setElectricalCurrent(parsingValue(parsingNbqInfo.getElectricalCurrent(), fileContent));
-//                                    inverterStatusData.setReactivePower(parsingValue(parsingNbqInfo.getReactivePower(), fileContent));
-//                                    inverterStatusData.setPowerFactor(parsingValue(parsingNbqInfo.getPowerFactor(), fileContent));
-//                                    inverterStatusData.setVoltage(parsingValue(parsingNbqInfo.getVoltage(), fileContent));
-//                                    inverterStatusData.setStatus(parsingStatus(parsingNbqInfo.getStatus(), fileContent));
-//                                    inverterStatusData.setEquipmentId(filterInverterInfos.get(0).getEquipmentNo());
-//                                    inverterStatusData.setStationCode(ftpParsingUrl.getStationCode());
-//                                    inverterStatusDataService.save(inverterStatusData);
-//                                    log.info("解析NBQ文件:{} 成功! O(∩_∩)O", file.getName());
-//                                    fileAnalysisStatusDto.setStatus("1");
-//                                } else {
-//                                    fileAnalysisStatusDto.setStatus("0");
-//                                    fileAnalysisStatusDto.setMessage("逆变器在本地无配置无法解析");
-//                                    log.info("nbq {} 在本地无配置无法解析", nbqName);
-//                                }
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("解析逆变器文件时间错误");
-//                                log.error("解析NBQ文件时间错误");
-//                            }
-//                        } else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("逆变器暂无多行解析方式");
-//                            log.info("nbq暂无多行解析方式");
-//                        }
-//                    }
-//                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析逆变器数据失败!");
-//            log.error("解析逆变器数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.nbq.name());
+
+        try {
+
+            //查询符合该场站的nbq配置信息
+            List<ParsingNbq> parsingNbqInfos = selectByStationCode(stationCode);
+            if (parsingNbqInfos.size() > 0) {
+
+                //解析文件内容以行为单位的 List<String>
+                List<String> fileContent = ParsingFileUtil.getFileContent(file);
+
+                //查询对应该场站路径下的逆变器信息
+                List<InverterInfo> inverterInfoList = inverterInfos.stream().filter(i->i.getStationCode().equals(stationCode)).collect(Collectors.toList());
+                //因为有可能该场站有多种解析配置,例如多个逆变器数据情况,需要循环解析信息
+                for (ParsingNbq parsingNbqInfo : parsingNbqInfos) {
+                        //判断数据类型是单行还是多行
+                        if (parsingNbqInfo.getDataType().equals(ParsingFieldUtil.SINGLE)) {
+                            /**
+                             * 逆变器和风机id  需要解析名称找出对应设备存入id
+                             *
+                             */
+                            String nbqName = parsingName(parsingNbqInfo.getEquipmentName(), fileContent);
+                            List<InverterInfo> filterInverterInfos = inverterInfoList.stream().filter(i -> i.getName().equals(nbqName)).collect(Collectors.toList());
+                            if (filterInverterInfos.size() > 0) {
+                                Long eqId = filterInverterInfos.get(0).getId();
+                                Date time = parsingTime(parsingNbqInfo.getTime(), fileContent);
+                                if (time != null) {
+                                    InverterStatusData inverterStatusData = new InverterStatusData();
+                                    inverterStatusData.setTime(time);
+
+                                    inverterStatusData.setActivePower(parsingValue(parsingNbqInfo.getActivePower(), fileContent));
+                                    inverterStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingNbqInfo.getCumulativeGeneratedEnergy(), fileContent));
+                                    inverterStatusData.setDayGridConnectedHours(parsingValue(parsingNbqInfo.getDayGridConnectedHours(), fileContent));
+                                    inverterStatusData.setDayElectricQuantity(parsingValue(parsingNbqInfo.getDayElectricQuantity(), fileContent));
+                                    inverterStatusData.setElectricalCurrent(parsingValue(parsingNbqInfo.getElectricalCurrent(), fileContent));
+                                    inverterStatusData.setReactivePower(parsingValue(parsingNbqInfo.getReactivePower(), fileContent));
+                                    inverterStatusData.setPowerFactor(parsingValue(parsingNbqInfo.getPowerFactor(), fileContent));
+                                    inverterStatusData.setVoltage(parsingValue(parsingNbqInfo.getVoltage(), fileContent));
+                                    inverterStatusData.setStatus(parsingStatus(parsingNbqInfo.getStatus(), fileContent));
+                                    inverterStatusData.setEquipmentId(eqId);
+                                    inverterStatusData.setStationCode(stationCode);
+                                    inverterStatusDataService.save(inverterStatusData);
+                                    log.info("解析NBQ文件:{} 成功! O(∩_∩)O", file.getName());
+                                    parsingResultDto.setStatus("success");
+                                } else {
+                                    parsingResultDto.setMessage("逆变器在本地无配置无法解析");
+                                    log.error("nbq {} 在本地无配置无法解析", nbqName);
+                                }
+                            } else {
+                                parsingResultDto.setStatus("0");
+                                parsingResultDto.setMessage("解析逆变器文件时间错误");
+                                log.error("解析NBQ文件时间错误");
+                            }
+                        } else {
+                            parsingResultDto.setMessage("逆变器暂无多行解析方式");
+                            log.error("nbq暂无多行解析方式");
+                        }
+                    
+                }
+            }
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析逆变器数据失败!");
+            log.error("解析逆变器数据失败! /(ㄒoㄒ)/~~", e);
+        } finally {
+            return parsingResultDto;
+        }
+
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingNbqs = baseMapper.selectList(null);
+        this.inverterInfos = inverterInfoService.list();
+        return false;
+    }
+
+    @Override
+    public List selectByStationCode(String stationCode) {
+        return parsingNbqs.stream().filter(p->p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
+
 }

+ 142 - 181
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingNwpServiceImpl.java

@@ -1,18 +1,20 @@
 package com.cpp.web.service.datafactory.impl;
 
-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.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingNwp;
 import com.cpp.web.domain.datafactory.dto.ParsingConfParam;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.NwpStation;
 import com.cpp.web.mapper.datafactory.ParsingNwpMapper;
-import com.cpp.web.service.cloud.NwpService;
+import com.cpp.web.service.cloud.NwpCloudService;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.datafactory.ParsingNwpService;
-import com.cpp.web.service.station.NwpHisService;
-import com.cpp.web.utils.FieldUtil;
-import com.cpp.web.utils.PUtil;
+import com.cpp.web.service.station.NwpStationService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
+import com.cpp.web.utils.ParsingUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -23,6 +25,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 测风塔解析业务层实现类
@@ -30,16 +33,17 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("nwpParsing")
 @AllArgsConstructor
 @Slf4j
 @Transactional
 public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, ParsingNwp> implements ParsingNwpService, ParsingInterface {
 
-    private final NwpHisService nwpHisService;
+    private final NwpStationService nwpStationService;
 
-    private final NwpService nwpService;
+    private final NwpCloudService nwpCloudService;
 
+    private List<ParsingNwp> parsingNwps = new ArrayList<>();
 
     @Override
     public boolean save(BaseParsing parsingInfo) {
@@ -51,175 +55,121 @@ public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, Parsing
         return removeById(id);
     }
 
-//    //文件解析
-//    /*
-//     * 解析配置格式规则:
-//     *
-//     *   m=>>4-20-4-1=>>3
-//     *   m:多行标识
-//     *   4-20:取值在4-20行
-//     *   -4:代表有层层高
-//     *   -1:代表取第一种层高
-//     *   3:第三列
-//     * */
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.NWP.getCode()+"");
-//
-//        try {
-//
-//            List<ParsingNwpInfo> parsingNwpInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingNwpInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            if (!parsingNwpInfos.isEmpty()) {
-//                for (ParsingNwpInfo parsingNwpInfo : parsingNwpInfos) {
-//                    //判断文件名是否符合配置
-//                    if (file.getName().contains(parsingNwpInfo.getFileName())) {
-//                        List<String> fileContent = FileUtil.getFileContent(file);
-//                        if (parsingNwpInfo.getDataType().equals(FieldUtil.MULTI)) {
-//                            Long time = parsingTime(parsingNwpInfo.getPreTime(), fileContent);
-//
-//
-//                            if (time != 0l) {
-//                                List<BigDecimal> ws10s = parsingNwpValue(parsingNwpInfo.getWs10(), fileContent);
-//                                List<BigDecimal> wd10s = parsingNwpValue(parsingNwpInfo.getWd10(), fileContent);
-//                                List<BigDecimal> ws30s = parsingNwpValue(parsingNwpInfo.getWs30(), fileContent);
-//                                List<BigDecimal> wd30s = parsingNwpValue(parsingNwpInfo.getWd30(), fileContent);
-//                                List<BigDecimal> ws50s = parsingNwpValue(parsingNwpInfo.getWs50(), fileContent);
-//                                List<BigDecimal> wd50s = parsingNwpValue(parsingNwpInfo.getWd50(), fileContent);
-//                                List<BigDecimal> ws70s = parsingNwpValue(parsingNwpInfo.getWs70(), fileContent);
-//                                List<BigDecimal> wd70s = parsingNwpValue(parsingNwpInfo.getWd70(), fileContent);
-//                                List<BigDecimal> ws80s = parsingNwpValue(parsingNwpInfo.getWs80(), fileContent);
-//                                List<BigDecimal> wd80s = parsingNwpValue(parsingNwpInfo.getWd80(), fileContent);
-//                                List<BigDecimal> ws90s = parsingNwpValue(parsingNwpInfo.getWs90(), fileContent);
-//                                List<BigDecimal> wd90s = parsingNwpValue(parsingNwpInfo.getWd90(), fileContent);
-//                                List<BigDecimal> ws100s = parsingNwpValue(parsingNwpInfo.getWs100(), fileContent);
-//                                List<BigDecimal> wd100s = parsingNwpValue(parsingNwpInfo.getWd100(), fileContent);
-//                                List<BigDecimal> ws170s = parsingNwpValue(parsingNwpInfo.getWs170(), fileContent);
-//                                List<BigDecimal> wd170s = parsingNwpValue(parsingNwpInfo.getWd170(), fileContent);
-//                                List<BigDecimal> directRadiations = parsingNwpValue(parsingNwpInfo.getDirectRadiation(), fileContent);
-//                                List<BigDecimal> lwrs = parsingNwpValue(parsingNwpInfo.getLwr(), fileContent);
-//                                List<BigDecimal> diffuseRadiations = parsingNwpValue(parsingNwpInfo.getDiffuseRadiation(), fileContent);
-//                                List<BigDecimal> rhs = parsingNwpValue(parsingNwpInfo.getRh(), fileContent);
-//                                List<BigDecimal> pressures = parsingNwpValue(parsingNwpInfo.getPressure(), fileContent);
-//                                List<BigDecimal> senfs = parsingNwpValue(parsingNwpInfo.getSenf(), fileContent);
-//                                List<BigDecimal> swrs = parsingNwpValue(parsingNwpInfo.getSwr(), fileContent);
-//                                List<BigDecimal> ts = parsingNwpValue(parsingNwpInfo.getT(), fileContent);
-//
-//                                List<NwpHis> nwpHisList = new ArrayList<>();
-//
-//                                List<Nwp> nwpList = new ArrayList<>();
-//                                //以十米风速为基准
-//                                for (int i = 0; i < ws10s.size(); i++) {
-//                                    NwpHis nwpHis = new NwpHis();
-//                                    Date localDateTime = new Date(time);
-//                                    nwpHis.setPreTime(localDateTime);
-//                                    nwpHis.setPreDate(localDateTime);
-//                                    nwpHis.setScDate(localDateTime);
-//                                    nwpHis.setScTime(localDateTime);
-//                                    nwpHis.setDirectRadiation(valueSet(directRadiations, i));
-//                                    nwpHis.setDiffuseRadiation(valueSet(diffuseRadiations, i));
-//                                    nwpHis.setForecastHowLongAgo(i / 96 + 1);
-//                                    nwpHis.setLwr(valueSet(lwrs, i));
-//                                    nwpHis.setPressure(valueSet(pressures, i));
-//                                    nwpHis.setRh(valueSet(rhs, i));
-//                                    nwpHis.setSenf(valueSet(senfs, i));
-//                                    nwpHis.setSwr(valueSet(swrs, i));
-//                                    nwpHis.setT(valueSet(ts, i));
-//                                    nwpHis.setWs10(valueSet(ws10s, i));
-//                                    nwpHis.setWd10(valueSet(wd10s, i));
-//                                    nwpHis.setWs30(valueSet(ws30s, i));
-//                                    nwpHis.setWd30(valueSet(wd30s, i));
-//                                    nwpHis.setWs50(valueSet(ws50s, i));
-//                                    nwpHis.setWd50(valueSet(wd50s, i));
-//                                    nwpHis.setWs70(valueSet(ws70s, i));
-//                                    nwpHis.setWd70(valueSet(wd70s, i));
-//                                    nwpHis.setWs80(valueSet(ws80s, i));
-//                                    nwpHis.setWd80(valueSet(wd80s, i));
-//                                    nwpHis.setWs90(valueSet(ws90s, i));
-//                                    nwpHis.setWd90(valueSet(wd90s, i));
-//                                    nwpHis.setWs100(valueSet(ws100s, i));
-//                                    nwpHis.setWd100(valueSet(wd100s, i));
-//                                    nwpHis.setWs170(valueSet(ws170s, i));
-//                                    nwpHis.setWd170(valueSet(wd170s, i));
-//                                    nwpHis.setForecastManufactor(parsingUrl.getForecastManufactor());
-//                                    nwpHis.setStationCode(parsingUrl.getStationCode());
-//
-//                                    nwpHisList.add(nwpHis);
-//
-//
-//
-//                                    Nwp nwp = new Nwp();
-//                                    nwp.setPreTime(localDateTime);
-//                                    nwp.setPreDate(localDateTime);
-//                                    nwp.setScDate(localDateTime);
-//                                    nwp.setScTime(localDateTime);
-//                                    nwp.setDirectRadiation(valueSet(directRadiations, i));
-//                                    nwp.setDiffuseRadiation(valueSet(diffuseRadiations, i));
-//                                    nwp.setLwr(valueSet(lwrs, i));
-//                                    nwp.setPressure(valueSet(pressures, i));
-//                                    nwp.setRh(valueSet(rhs, i));
-//                                    nwp.setSenf(valueSet(senfs, i));
-//                                    nwp.setSwr(valueSet(swrs, i));
-//                                    nwp.setT(valueSet(ts, i));
-//                                    nwp.setWs10(valueSet(ws10s, i));
-//                                    nwp.setWd10(valueSet(wd10s, i));
-//                                    nwp.setWs30(valueSet(ws30s, i));
-//                                    nwp.setWd30(valueSet(wd30s, i));
-//                                    nwp.setWs50(valueSet(ws50s, i));
-//                                    nwp.setWd50(valueSet(wd50s, i));
-//                                    nwp.setWs70(valueSet(ws70s, i));
-//                                    nwp.setWd70(valueSet(wd70s, i));
-//                                    nwp.setWs80(valueSet(ws80s, i));
-//                                    nwp.setWd80(valueSet(wd80s, i));
-//                                    nwp.setWs90(valueSet(ws90s, i));
-//                                    nwp.setWd90(valueSet(wd90s, i));
-//                                    nwp.setWs100(valueSet(ws100s, i));
-//                                    nwp.setWd100(valueSet(wd100s, i));
-//                                    nwp.setWs170(valueSet(ws170s, i));
-//                                    nwp.setWd170(valueSet(wd170s, i));
-//                                    nwp.setForecastManufactor(parsingUrl.getForecastManufactor());
-//                                    nwp.setStationCode(parsingUrl.getStationCode());
-//
-//                                    nwpList.add(nwp);
-//                                    time += Constant.INTERVALTIME;
-//                                }
-//
-//
-//
-//                                Date startTime = nwpHisList.get(0).getPreTime();
-//                                Date endTime = nwpHisList.get(nwpHisList.size() - 1).getPreTime();
-//                                nwpHisService.saveBatch(nwpHisList);
-//                                LambdaQueryWrapper<Nwp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-//                                lambdaQueryWrapper.eq(Nwp::getStationCode, parsingUrl.getStationCode());
-//                                lambdaQueryWrapper.between(Nwp::getPreTime, startTime, endTime);
-//                                nwpService.remove(lambdaQueryWrapper);
-////
-//                                nwpService.saveBatch(nwpList);
-//
-//                                fileAnalysisStatusDto.setStatus("1");
-//                                log.info("解析Nwp文件:{} 成功! O(∩_∩)O", file.getName());
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("解析Nwp文件时间错误");
-//                                log.error("解析Nwp文件时间错误");
-//                            }
-//                        } else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("Nwp暂无单行解析方式");
-//                            log.info("nwp暂无单行解析方式");
-//                        }
-//                    }
-//                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析Nwp数据失败");
-//            log.error("解析Nwp数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.nwp.name());
+
+        try {
+
+            List<ParsingNwp> parsingNwpInfos = selectByStationCode(stationCode);
+            if (!parsingNwpInfos.isEmpty()) {
+                for (ParsingNwp parsingNwpInfo : parsingNwpInfos) {
+                        List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                        if (parsingNwpInfo.getDataType().equals(ParsingFieldUtil.MULTI)) {
+                            Date forecastTime = parsingTime(parsingNwpInfo.getPreTime(), fileContent);
+                            Date time = forecastTime;
+                            if (time != null) {
+                                List<BigDecimal> ws10s = parsingNwpValue(parsingNwpInfo.getWs10(), fileContent);
+                                List<BigDecimal> wd10s = parsingNwpValue(parsingNwpInfo.getWd10(), fileContent);
+                                List<BigDecimal> ws30s = parsingNwpValue(parsingNwpInfo.getWs30(), fileContent);
+                                List<BigDecimal> wd30s = parsingNwpValue(parsingNwpInfo.getWd30(), fileContent);
+                                List<BigDecimal> ws50s = parsingNwpValue(parsingNwpInfo.getWs50(), fileContent);
+                                List<BigDecimal> wd50s = parsingNwpValue(parsingNwpInfo.getWd50(), fileContent);
+                                List<BigDecimal> ws70s = parsingNwpValue(parsingNwpInfo.getWs70(), fileContent);
+                                List<BigDecimal> wd70s = parsingNwpValue(parsingNwpInfo.getWd70(), fileContent);
+                                List<BigDecimal> ws80s = parsingNwpValue(parsingNwpInfo.getWs80(), fileContent);
+                                List<BigDecimal> wd80s = parsingNwpValue(parsingNwpInfo.getWd80(), fileContent);
+                                List<BigDecimal> ws90s = parsingNwpValue(parsingNwpInfo.getWs90(), fileContent);
+                                List<BigDecimal> wd90s = parsingNwpValue(parsingNwpInfo.getWd90(), fileContent);
+                                List<BigDecimal> ws100s = parsingNwpValue(parsingNwpInfo.getWs100(), fileContent);
+                                List<BigDecimal> wd100s = parsingNwpValue(parsingNwpInfo.getWd100(), fileContent);
+                                List<BigDecimal> ws170s = parsingNwpValue(parsingNwpInfo.getWs170(), fileContent);
+                                List<BigDecimal> wd170s = parsingNwpValue(parsingNwpInfo.getWd170(), fileContent);
+                                List<BigDecimal> directRadiations = parsingNwpValue(parsingNwpInfo.getDirectRadiation(), fileContent);
+                                List<BigDecimal> lwrs = parsingNwpValue(parsingNwpInfo.getLwr(), fileContent);
+                                List<BigDecimal> diffuseRadiations = parsingNwpValue(parsingNwpInfo.getDiffuseRadiation(), fileContent);
+                                List<BigDecimal> rhs = parsingNwpValue(parsingNwpInfo.getRh(), fileContent);
+                                List<BigDecimal> pressures = parsingNwpValue(parsingNwpInfo.getPressure(), fileContent);
+                                List<BigDecimal> senfs = parsingNwpValue(parsingNwpInfo.getSenf(), fileContent);
+                                List<BigDecimal> swrs = parsingNwpValue(parsingNwpInfo.getSwr(), fileContent);
+                                List<BigDecimal> ts = parsingNwpValue(parsingNwpInfo.getT(), fileContent);
+
+                                List<NwpStation> nwpStationList = new ArrayList<>();
+                                //以十米风速为基准
+                                for (int i = 0; i < ws10s.size(); i++) {
+                                    NwpStation nwpStation = new NwpStation();
+                                    nwpStation.setTime(time);
+                                    nwpStation.setDirectRadiation(valueSet(directRadiations, i));
+                                    nwpStation.setDiffuseRadiation(valueSet(diffuseRadiations, i));
+                                    nwpStation.setForecastHowLongAgo(calcHowLongAgo(forecastTime,time));
+                                    nwpStation.setLwr(valueSet(lwrs, i));
+                                    nwpStation.setPressure(valueSet(pressures, i));
+                                    nwpStation.setRh(valueSet(rhs, i));
+                                    nwpStation.setSenf(valueSet(senfs, i));
+                                    nwpStation.setSwr(valueSet(swrs, i));
+                                    nwpStation.setT(valueSet(ts, i));
+                                    nwpStation.setWs10(valueSet(ws10s, i));
+                                    nwpStation.setWd10(valueSet(wd10s, i));
+                                    nwpStation.setWs30(valueSet(ws30s, i));
+                                    nwpStation.setWd30(valueSet(wd30s, i));
+                                    nwpStation.setWs50(valueSet(ws50s, i));
+                                    nwpStation.setWd50(valueSet(wd50s, i));
+                                    nwpStation.setWs70(valueSet(ws70s, i));
+                                    nwpStation.setWd70(valueSet(wd70s, i));
+                                    nwpStation.setWs80(valueSet(ws80s, i));
+                                    nwpStation.setWd80(valueSet(wd80s, i));
+                                    nwpStation.setWs90(valueSet(ws90s, i));
+                                    nwpStation.setWd90(valueSet(wd90s, i));
+                                    nwpStation.setWs100(valueSet(ws100s, i));
+                                    nwpStation.setWd100(valueSet(wd100s, i));
+                                    nwpStation.setWs170(valueSet(ws170s, i));
+                                    nwpStation.setWd170(valueSet(wd170s, i));
+                                    nwpStation.setStationCode(stationCode);
+
+                                    nwpStationList.add(nwpStation);
+
+                                    time = new Date(time.getTime() + 900000L);
+                                }
+
+                                nwpStationService.saveBatch(nwpStationList);
+
+                                parsingResultDto.setStatus("success");
+                                log.info("解析Nwp文件:{} 成功! O(∩_∩)O", file.getName());
+                            } else {
+                                parsingResultDto.setMessage("解析Nwp文件时间错误");
+                                log.error("解析Nwp文件时间错误");
+                            }
+                        } else {
+                            parsingResultDto.setMessage("Nwp暂无单行解析方式");
+                            log.error("nwp暂无单行解析方式");
+                        }
+                    }
+                }
+
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析Nwp数据失败");
+            log.error("解析Nwp数据失败! /(ㄒoㄒ)/~~", e);
+        } finally {
+            return parsingResultDto;
+        }
+
+
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingNwps = baseMapper.selectList(null);
+        return false;
+    }
+
+    @Override
+    public List selectByStationCode(String stationCode) {
+        return this.parsingNwps.stream().filter(p->p.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    }
+
 
 
     protected List<BigDecimal> parsingNwpValue(String sign, List<String> fileContent) {
@@ -227,7 +177,7 @@ public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, Parsing
 
         try {
             if (sign != null && !sign.equals("")) {
-                ParsingConfParam config = FieldUtil.getConfig(sign);
+                ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
                 String[] lineNumber = config.getLineNumber().split("-");
                 if (lineNumber.length > 2) {
                     int startLine = Integer.parseInt(lineNumber[0]) - 1;
@@ -236,7 +186,7 @@ public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, Parsing
                     int no = Integer.parseInt(lineNumber[3]) - 1 ;
 
                     for (int i = startLine + no; i <= endLine; i += size) {
-                        String[] strings = PUtil.splitLineWithSpace(fileContent.get(i));
+                        String[] strings = ParsingUtil.splitLineWithSpace(fileContent.get(i));
                         String result = strings[Integer.parseInt(config.getRowNumber()) - 1];
 
                         fpValues.add(new BigDecimal(result));
@@ -248,7 +198,7 @@ public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, Parsing
                     int endLine = Integer.parseInt(lineNumber[1]) - 1;
 
                     for (int i = startLine; i <= endLine; i++) {
-                        String[] strings = PUtil.splitLineWithSpace(fileContent.get(i));
+                        String[] strings = ParsingUtil.splitLineWithSpace(fileContent.get(i));
                         String result = strings[Integer.parseInt(config.getRowNumber()) - 1];
 
                         fpValues.add(new BigDecimal(result));
@@ -272,4 +222,15 @@ public class ParsingNwpServiceImpl extends ServiceImpl<ParsingNwpMapper, Parsing
         }
 
     }
+
+
+    /**
+     * 计算D+x中的x
+     *
+     * @param baseTime
+     * @param time
+     */
+    public Integer calcHowLongAgo(Date baseTime, Date time) {
+        return ((int) (time.getTime() - baseTime.getTime() % 86400000L)) + 1;
+    }
 }

+ 91 - 73
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingQxzServiceImpl.java

@@ -4,19 +4,27 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingQxz;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
+import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.WeatherStationInfo;
+import com.cpp.web.domain.station.WeatherStationStatusData;
 import com.cpp.web.mapper.datafactory.ParsingQxzMapper;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.datafactory.ParsingQxzService;
 import com.cpp.web.service.station.WeatherStationInfoService;
 import com.cpp.web.service.station.WeatherStationStatusDataService;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 气象站解析业务层实现类
@@ -24,19 +32,20 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("qxzParsing")
 @Slf4j
 @AllArgsConstructor
 @Transactional
 public class ParsingQxzServiceImpl extends ServiceImpl<ParsingQxzMapper, ParsingQxz> implements ParsingQxzService, ParsingInterface {
 
-
-    private final Long intervalTime = 300000L;
-
     private final WeatherStationStatusDataService weatherStationStatusDataService;
 
     private final WeatherStationInfoService weatherStationInfoService;
 
+    private List<ParsingQxz> parsingQxzs = new ArrayList<>();
+
+    private List<WeatherStationInfo> weatherStationInfos = new ArrayList<>();
+
     @Override
     public boolean save(BaseParsing parsingInfo) {
         return save((ParsingQxz) parsingInfo);
@@ -46,73 +55,82 @@ public class ParsingQxzServiceImpl extends ServiceImpl<ParsingQxzMapper, Parsing
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.QXZ.getCode()+"");
-//        try {
-//
-//            List<ParsingQxzInfo> parsingQxzInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingQxzInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            if (parsingQxzInfos.size() > 0) {
-//                List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.list(Wrappers.lambdaQuery(WeatherStationInfo.class)
-//                        .eq(WeatherStationInfo::getStationCode, parsingUrl.getStationCode()));
-//                if (weatherStationInfoList.size() > 0) {
-//                    List<String> fileContent = FileUtil.getFileContent(file);
-//                    for (ParsingQxzInfo parsingQxzInfo : parsingQxzInfos) {
-//                        //判断文件名是否符合配置
-//                        if (file.getName().indexOf(parsingQxzInfo.getFileName()) >= 0) {
-//                            if (parsingQxzInfo.getDataType().equals(FieldUtil.SINGLE)) {
-//                                Long time = parsingTime(parsingQxzInfo.getTime(), fileContent);
-//                                if (time != 0L) {
-//                                    WeatherStationStatusData w = new WeatherStationStatusData();
-//                                    w.setTime(new Date(time));
-//                                    w.setAirT(parsingValue(parsingQxzInfo.getAirT(), fileContent));
-//                                    w.setCellT(parsingValue(parsingQxzInfo.getCellT(), fileContent));
-//                                    w.setDiffuseR(parsingValue(parsingQxzInfo.getDiffuseR(), fileContent));
-//                                    w.setDiffuseRDA(parsingValue(parsingQxzInfo.getDiffuseRDA(), fileContent));
-//                                    w.setDirectR(parsingValue(parsingQxzInfo.getDirectR(), fileContent));
-//                                    w.setDirectRDA(parsingValue(parsingQxzInfo.getDirectRDA(), fileContent));
-//                                    w.setGlobalR(parsingValue(parsingQxzInfo.getGlobalR(), fileContent));
-//                                    w.setGlobalRDA(parsingValue(parsingQxzInfo.getGlobalRDA(), fileContent));
-//                                    w.setHourDA(parsingValue(parsingQxzInfo.getHourDA(), fileContent));
-//                                    w.setObliqueR(parsingValue(parsingQxzInfo.getObliqueR(), fileContent));
-//                                    w.setObliqueRDA(parsingValue(parsingQxzInfo.getObliqueRDA(), fileContent));
-//                                    w.setP(parsingValue(parsingQxzInfo.getP(), fileContent));
-//                                    w.setRh(parsingValue(parsingQxzInfo.getRh(), fileContent));
-//                                    w.setWd(parsingValue(parsingQxzInfo.getWd(), fileContent));
-//                                    w.setWs(parsingValue(parsingQxzInfo.getWs(), fileContent));
-//                                    w.setStatus(parsingStatus(parsingQxzInfo.getStatus(), fileContent));
-//                                    w.setStationCode(parsingQxzInfo.getStationCode());
-//                                    w.setEquipmentId(weatherStationInfoList.get(0).getEquipmentNo());
-//                                    weatherStationStatusDataService.save(w);
-//                                    fileAnalysisStatusDto.setStatus("1");
-//                                    log.info("解析QXZ文件:{} 成功! O(∩_∩)O", file.getName());
-//                                } else {
-//                                    fileAnalysisStatusDto.setStatus("0");
-//                                    fileAnalysisStatusDto.setMessage("解析气象站文件时间错误");
-//                                    log.error("解析QXZ文件时间错误");
-//                                }
-//                            } else {
-//                                fileAnalysisStatusDto.setStatus("0");
-//                                fileAnalysisStatusDto.setMessage("气象站暂无多行解析方式");
-//                                log.info("qxz暂无多行解析方式");
-//                            }
-//                        }
-//                    }
-//                } else {
-//                    fileAnalysisStatusDto.setStatus("0");
-//                    fileAnalysisStatusDto.setMessage("气象站未配置作为解析使用设备");
-//                    log.info("qxz未配置作为解析使用设备");
-//                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析气象站数据失败!");
-//            log.error("解析气象站数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
+
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.qxz.name());
+        try {
+
+            List<ParsingQxz> parsingQxzInfos = selectByStationCode(stationCode);
+            if (parsingQxzInfos.size() > 0) {
+                List<WeatherStationInfo> weatherStationInfoList = weatherStationInfos.stream().filter(w->w.getStationCode().equals(stationCode)).collect(Collectors.toList());
+                if (weatherStationInfoList.size() > 0) {
+                    Long eqId = weatherStationInfoList.get(0).getId();
+                    List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                    for (ParsingQxz parsingQxzInfo : parsingQxzInfos) {
+                        //判断文件名是否符合配置
+                            if (parsingQxzInfo.getDataType().equals(ParsingFieldUtil.SINGLE)) {
+                                Date time = parsingTime(parsingQxzInfo.getTime(), fileContent);
+                                if (time != null) {
+                                    WeatherStationStatusData w = new WeatherStationStatusData();
+                                    w.setTime(time);
+                                    w.setAirT(parsingValue(parsingQxzInfo.getAirT(), fileContent));
+                                    w.setCellT(parsingValue(parsingQxzInfo.getCellT(), fileContent));
+                                    w.setDiffuseR(parsingValue(parsingQxzInfo.getDiffuseR(), fileContent));
+                                    w.setDiffuseRDA(parsingValue(parsingQxzInfo.getDiffuseRDA(), fileContent));
+                                    w.setDirectR(parsingValue(parsingQxzInfo.getDirectR(), fileContent));
+                                    w.setDirectRDA(parsingValue(parsingQxzInfo.getDirectRDA(), fileContent));
+                                    w.setGlobalR(parsingValue(parsingQxzInfo.getGlobalR(), fileContent));
+                                    w.setGlobalRDA(parsingValue(parsingQxzInfo.getGlobalRDA(), fileContent));
+                                    w.setHourDA(parsingValue(parsingQxzInfo.getHourDA(), fileContent));
+                                    w.setObliqueR(parsingValue(parsingQxzInfo.getObliqueR(), fileContent));
+                                    w.setObliqueRDA(parsingValue(parsingQxzInfo.getObliqueRDA(), fileContent));
+                                    w.setP(parsingValue(parsingQxzInfo.getP(), fileContent));
+                                    w.setRh(parsingValue(parsingQxzInfo.getRh(), fileContent));
+                                    w.setWd(parsingValue(parsingQxzInfo.getWd(), fileContent));
+                                    w.setWs(parsingValue(parsingQxzInfo.getWs(), fileContent));
+                                    w.setStatus(parsingStatus(parsingQxzInfo.getStatus(), fileContent));
+                                    w.setStationCode(parsingQxzInfo.getStationCode());
+                                    w.setEquipmentId(eqId);
+                                    weatherStationStatusDataService.save(w);
+                                    parsingResultDto.setStatus("success");
+                                    log.info("解析QXZ文件:{} 成功! O(∩_∩)O", file.getName());
+                                } else {
+                                    parsingResultDto.setMessage("解析气象站文件时间错误");
+                                    log.error("解析QXZ文件时间错误");
+                                }
+                            } else {
+                                parsingResultDto.setMessage("气象站暂无多行解析方式");
+                                log.error("qxz暂无多行解析方式");
+                            }
+
+                    }
+                } else {
+                    parsingResultDto.setMessage("气象站未配置作为解析使用设备");
+                    log.error("qxz未配置作为解析使用设备");
+                }
+            }
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析气象站数据失败!");
+            log.error("解析气象站数据失败! /(ㄒoㄒ)/~~", e);
+        } finally {
+            return parsingResultDto;
+        }
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        this.parsingQxzs = baseMapper.selectList(null);
+        this.weatherStationInfos = weatherStationInfoService.list();
+        return false;
+    }
+
+    @Override
+    public List selectByStationCode(String stationCode) {
+        return null;
+    }
+
 }

+ 88 - 108
cpp-admin/src/main/java/com/cpp/web/service/datafactory/impl/ParsingRpServiceImpl.java

@@ -1,17 +1,19 @@
 package com.cpp.web.service.datafactory.impl;
 
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.datafactory.BaseParsing;
 import com.cpp.web.domain.datafactory.ParsingRp;
 import com.cpp.web.domain.datafactory.dto.ParsingConfParam;
+import com.cpp.web.domain.datafactory.dto.ParsingResultDto;
 import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
+import com.cpp.web.domain.station.PowerStationStatusData;
 import com.cpp.web.mapper.datafactory.ParsingRpMapper;
 import com.cpp.web.service.datafactory.ParsingInterface;
 import com.cpp.web.service.datafactory.ParsingRpService;
 import com.cpp.web.service.station.PowerStationStatusDataService;
-import com.cpp.web.utils.FieldUtil;
-import com.cpp.web.utils.PUtil;
+import com.cpp.web.utils.ParsingFieldUtil;
+import com.cpp.web.utils.ParsingFileUtil;
+import com.cpp.web.utils.ParsingUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -20,10 +22,8 @@ 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.LocalDateTime;
-import java.time.ZoneId;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -32,7 +32,7 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 18:07:03
  */
-@Service
+@Service("rpParsing")
 @Slf4j
 @AllArgsConstructor
 @Transactional
@@ -40,6 +40,8 @@ public class ParsingRpServiceImpl extends ServiceImpl<ParsingRpMapper, ParsingRp
 
     private final PowerStationStatusDataService powerStationStatusDataService;
 
+    private List<ParsingRp> parsingRps = new ArrayList<>();
+
     @Override
     public boolean save(BaseParsing parsingInfo) {
         return save((ParsingRp) parsingInfo);
@@ -49,69 +51,84 @@ public class ParsingRpServiceImpl extends ServiceImpl<ParsingRpMapper, ParsingRp
     public boolean deleteById(Long id) {
         return removeById(id);
     }
-//
-//    @Override
-//    public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
-//        FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
-//        fileAnalysisStatusDto.setFileName(file.getName());
-//        fileAnalysisStatusDto.setFileType(FileTypeEnum.RP.getCode()+"");
-//
-//        try {
-//            List<ParsingRpInfo> parsingRpInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingRpInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
-//            if (!parsingRpInfos.isEmpty()) {
-//                ParsingRpInfo parsingRpInfo = parsingRpInfos.get(0);
-//
-//                //判断文件名是否符合配置
-//                if (file.getName().contains(parsingRpInfo.getFileName())) {
-//
-//                    List<String> fileContent = FileUtil.getFileContent(file);
-//                    if (parsingRpInfo.getDataType().equals(FieldUtil.SINGLE)) {
-//                        BigDecimal bigDecimal;
-//                        if (parsingRpInfo.getAbleValue() != null) ;
-//                        bigDecimal = parsingValue(parsingRpInfo.getRealValue(), fileContent);
-//
-//
-//                        Long time = parsingForecastTime(parsingRpInfo.getTime(), fileContent);
-//
-//                        if (time != 0l) {
-//                            PowerStationStatusData powerStationStatusData = new PowerStationStatusData();
-//                            powerStationStatusData.setStationCode(parsingUrl.getStationCode());
-////                                powerStationStatusData.setAbleValue(bigDecimals.get(0));
-//                            powerStationStatusData.setRealValue(bigDecimal);
-//                            LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
-//                            powerStationStatusData.setTime(localDateTime);
-//
-//                            powerStationStatusDataService.save(powerStationStatusData);
-//
-//                            log.info("解析RP文件:{} 成功! O(∩_∩)O", file.getName());
-//                            fileAnalysisStatusDto.setStatus("1");
-//                        } else {
-//                            fileAnalysisStatusDto.setStatus("0");
-//                            fileAnalysisStatusDto.setMessage("解析实际功率文件时间错误");
-//                            log.error("解析RP文件时间错误");
-//                        }
-//                    } else {
-//                        fileAnalysisStatusDto.setStatus("0");
-//                        fileAnalysisStatusDto.setMessage("实际功率暂无单行解析方式");
-//                        log.info("RP暂无单行解析方式");
-//                    }
-//                }
-//            }
-//        } catch (Exception e) {
-//            fileAnalysisStatusDto.setStatus("0");
-//            fileAnalysisStatusDto.setMessage("解析实际功率数据失败!");
-//            log.error("解析实际功率数据失败! /(ㄒoㄒ)/~~", e);
-//        } finally {
-//            return fileAnalysisStatusDto;
-//        }
-//    }
-
-
-    protected Long parsingForecastTime(String sign, List<String> fileContent) {
-        Long forecastTime = 0l;
+
+
+    @Override
+    public ParsingResultDto parsing(File file, String stationCode) {
+        ParsingResultDto parsingResultDto = new ParsingResultDto();
+        parsingResultDto.setFileName(file.getName());
+        parsingResultDto.setFileType(FileTypeEnum.rp.name());
+
+        try {
+            List<ParsingRp> parsingRpInfos = selectByStationCode(stationCode);
+            if (!parsingRpInfos.isEmpty()) {
+                ParsingRp parsingRpInfo = parsingRpInfos.get(0);
+
+                List<String> fileContent = ParsingFileUtil.getFileContent(file);
+                if (parsingRpInfo.getDataType().equals(ParsingFieldUtil.SINGLE)) {
+
+                    Date time = parsingForecastTime(parsingRpInfo.getTime(), fileContent);
+
+                    if (time != null) {
+
+                        BigDecimal realValue = new BigDecimal(-99);
+                        if (parsingRpInfo.getRealValue() != null)
+                            realValue = parsingValue(parsingRpInfo.getRealValue(), fileContent);
+
+                        BigDecimal ableValue = new BigDecimal(-99);
+                        if (parsingRpInfo.getAbleValue() != null)
+                            ableValue = parsingValue(parsingRpInfo.getAbleValue(), fileContent);
+
+                        BigDecimal theoryValue = new BigDecimal(-99);
+                        if (parsingRpInfo.getTheoryValue() != null)
+                            theoryValue = parsingValue(parsingRpInfo.getTheoryValue(), fileContent);
+
+
+                        PowerStationStatusData powerStationStatusData = new PowerStationStatusData();
+                        powerStationStatusData.setStationCode(stationCode);
+                        powerStationStatusData.setTheoryValue(theoryValue);
+                        powerStationStatusData.setAbleValue(ableValue);
+                        powerStationStatusData.setRealValue(realValue);
+                        powerStationStatusData.setTime(time);
+
+                        powerStationStatusDataService.save(powerStationStatusData);
+
+                        log.info("解析RP文件:{} 成功! O(∩_∩)O", file.getName());
+                        parsingResultDto.setStatus("success");
+                    } else {
+                        parsingResultDto.setMessage("解析实际功率文件时间错误");
+                        log.error("解析RP文件时间错误");
+                    }
+                } else {
+                    parsingResultDto.setMessage("实际功率暂无单行解析方式");
+                    log.error("RP暂无单行解析方式");
+                }
+
+            }
+        } catch (Exception e) {
+            parsingResultDto.setMessage("解析实际功率数据失败!");
+            log.error("解析实际功率数据失败! /(ㄒoㄒ)/~~", e);
+        } finally {
+            return parsingResultDto;
+        }
+    }
+
+    @Override
+    public boolean activationParsingConf() {
+        return false;
+    }
+
+    @Override
+    public List selectByStationCode(String stationCode) {
+        return null;
+    }
+
+
+    protected Date parsingForecastTime(String sign, List<String> fileContent) {
+        Date time = null;
         try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
-            String s = fileContent.get(PUtil.noParseInt(config.getLineNumber()));
+            ParsingConfParam config = ParsingFieldUtil.getConfig(sign);
+            String s = fileContent.get(ParsingUtil.noParseInt(config.getLineNumber()));
             int signIndex = s.indexOf(config.getDataSign());
             String result;
             if (signIndex > 0) {
@@ -124,7 +141,7 @@ public class ParsingRpServiceImpl extends ServiceImpl<ParsingRpMapper, ParsingRp
 
                 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(config.getFormat());
 
-                forecastTime = simpleDateFormat.parse(result).getTime();
+                time = simpleDateFormat.parse(result);
 
                 log.info("解析实际功率【时间】成功==》开始时间为:{}", result);
             } else {
@@ -134,48 +151,11 @@ public class ParsingRpServiceImpl extends ServiceImpl<ParsingRpMapper, ParsingRp
             log.error("解析实际功率【时间】失败");
             e.printStackTrace();
         } finally {
-            return forecastTime;
+            return time;
         }
 
     }
 
 
-    /*
-     * 解析配置格式规则:
-     *   s=>>1=>>entity=
-     *   s:单行标识
-     *   1:取值在1行
-     *   entity=:键标记标记
-     *
-     *   m=>>4-20=>>3
-     *   m:多行标识
-     *   4-20:取值在4-20行
-     *   3:第三列
-     * */
-    protected List<BigDecimal> parsingFpValue(String sign, List<String> fileContent) {
-        List<BigDecimal> fpValues = new ArrayList<>();
-        try {
-            ParsingConfParam config = FieldUtil.getConfig(sign);
-
-
-            String[] lineNumber = config.getLineNumber().split("-");
-            int startLine = PUtil.noParseInt(lineNumber[0]);
-            int endLine = PUtil.noParseInt(lineNumber[1]);
-
-            for (int i = startLine; i <= endLine; i++) {
-                String[] strings = PUtil.splitLineWithSpace(fileContent.get(i));
-                String result = strings[PUtil.noParseInt(config.getRowNumber())];
-
-                fpValues.add(new BigDecimal(result));
-            }
-
-            log.info("解析短期【实际功率】成功!!!==》记录数:{}", fpValues.size());
-        } catch (RuntimeException e) {
-            log.error("解析短期【实际功率】失败");
-            e.printStackTrace();
-        } finally {
-            return fpValues;
-        }
-    }
 
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerShortTermHisService.java → cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerShortTermStationService.java

@@ -11,7 +11,7 @@ import java.util.List;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface ForecastPowerShortTermHisService extends IService<ForecastPowerShortTermStation> {
+public interface ForecastPowerShortTermStationService extends IService<ForecastPowerShortTermStation> {
 
     /**
      * 根据时间 提前多久预测 场站编号查询数据

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerUltraShortTermHisService.java → cpp-admin/src/main/java/com/cpp/web/service/station/ForecastPowerUltraShortTermStationService.java

@@ -12,7 +12,7 @@ import java.util.List;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface ForecastPowerUltraShortTermHisService extends IService<ForecastPowerUltraShortTermStation> {
+public interface ForecastPowerUltraShortTermStationService extends IService<ForecastPowerUltraShortTermStation> {
     /**
      * 根据场站编号和时间范围来查询
      *

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/service/station/NwpHisService.java → cpp-admin/src/main/java/com/cpp/web/service/station/NwpStationService.java

@@ -9,6 +9,6 @@ import com.cpp.web.domain.station.NwpStation;
  * @author tl
  * @date 2024-09-23 15:28:33
  */
-public interface NwpHisService extends IService<NwpStation> {
+public interface NwpStationService extends IService<NwpStation> {
 
 }

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerShortTermHisServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerShortTermStationServiceImpl.java

@@ -3,8 +3,8 @@ package com.cpp.web.service.station.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.station.ForecastPowerShortTermStation;
-import com.cpp.web.mapper.station.ForecastPowerShortTermHisMapper;
-import com.cpp.web.service.station.ForecastPowerShortTermHisService;
+import com.cpp.web.mapper.station.ForecastPowerShortTermStationMapper;
+import com.cpp.web.service.station.ForecastPowerShortTermStationService;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -17,7 +17,7 @@ import java.util.List;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class ForecastPowerShortTermHisServiceImpl extends ServiceImpl<ForecastPowerShortTermHisMapper, ForecastPowerShortTermStation> implements ForecastPowerShortTermHisService {
+public class ForecastPowerShortTermStationServiceImpl extends ServiceImpl<ForecastPowerShortTermStationMapper, ForecastPowerShortTermStation> implements ForecastPowerShortTermStationService {
     @Override
     public ForecastPowerShortTermStation findByForecastTimeAndForecastHowLongAgoAndStationCodeAndForecastManufactor(Long pointEndTime, int howLongAgo, String stationCode, String forecastManufactor) {
         QueryWrapper<ForecastPowerShortTermStation> wrapper = new QueryWrapper<>();

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerUltraShortTermHisServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/station/impl/ForecastPowerUltraShortTermStationServiceImpl.java

@@ -3,8 +3,8 @@ package com.cpp.web.service.station.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.station.ForecastPowerUltraShortTermStation;
-import com.cpp.web.mapper.station.ForecastPowerUltraShortTermHisMapper;
-import com.cpp.web.service.station.ForecastPowerUltraShortTermHisService;
+import com.cpp.web.mapper.station.ForecastPowerUltraShortTermStationMapper;
+import com.cpp.web.service.station.ForecastPowerUltraShortTermStationService;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -17,7 +17,7 @@ import java.util.List;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class ForecastPowerUltraShortTermHisServiceImpl extends ServiceImpl<ForecastPowerUltraShortTermHisMapper, ForecastPowerUltraShortTermStation> implements ForecastPowerUltraShortTermHisService {
+public class ForecastPowerUltraShortTermStationServiceImpl extends ServiceImpl<ForecastPowerUltraShortTermStationMapper, ForecastPowerUltraShortTermStation> implements ForecastPowerUltraShortTermStationService {
     @Override
     public List<ForecastPowerUltraShortTermStation> findByStationCodeAndStartTimeAndEndTimeAndHowLongAgoAndForecastManufactor(String stationCode, Date startTime, Date endTime, Integer cdqPoint, String forecastManufactor) {
         QueryWrapper<ForecastPowerUltraShortTermStation> wrapper = new QueryWrapper<>();

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/service/station/impl/NwpHisServiceImpl.java → cpp-admin/src/main/java/com/cpp/web/service/station/impl/NwpStationServiceImpl.java

@@ -2,8 +2,8 @@ package com.cpp.web.service.station.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cpp.web.domain.station.NwpStation;
-import com.cpp.web.mapper.station.NwpHisMapper;
-import com.cpp.web.service.station.NwpHisService;
+import com.cpp.web.mapper.station.NwpStationMapper;
+import com.cpp.web.service.station.NwpStationService;
 import org.springframework.stereotype.Service;
 
 /**
@@ -13,6 +13,6 @@ import org.springframework.stereotype.Service;
  * @date 2024-09-23 15:28:33
  */
 @Service
-public class NwpHisServiceImpl extends ServiceImpl<NwpHisMapper, NwpStation> implements NwpHisService {
+public class NwpStationServiceImpl extends ServiceImpl<NwpStationMapper, NwpStation> implements NwpStationService {
 
 }

+ 8 - 13
cpp-admin/src/main/java/com/cpp/web/service/station/impl/PowerStationStatusDataServiceImpl.java

@@ -1,24 +1,19 @@
 package com.cpp.web.service.station.impl;
 
-import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.cpp.web.domain.cloud.ForecastPowerShortTermCloud;
-import com.cpp.web.domain.cloud.ForecastPowerUltraShortTermCloud;
 import com.cpp.web.domain.station.PowerStationStatusData;
 import com.cpp.web.mapper.station.PowerStationStatusDataMapper;
-import com.cpp.web.service.cloud.ForecastPowerShortTermService;
-import com.cpp.web.service.cloud.ForecastPowerUltraShortTermService;
-import com.cpp.web.service.cloud.NwpService;
+import com.cpp.web.service.cloud.ForecastPowerShortTermCloudService;
+import com.cpp.web.service.cloud.ForecastPowerUltraShortTermCloudService;
+import com.cpp.web.service.cloud.NwpCloudService;
 import com.cpp.web.service.station.*;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * cpp_power_station_status_data
@@ -29,12 +24,12 @@ import java.util.stream.Collectors;
 @Service
 @RequiredArgsConstructor
 public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationStatusDataMapper, PowerStationStatusData> implements PowerStationStatusDataService {
-    private final ForecastPowerUltraShortTermHisService forecastPowerUltraShortTermHisService;
-    private final ForecastPowerUltraShortTermService forecastPowerUltraShortTermService;
-    private final ForecastPowerShortTermService forecastPowerShortTermService;
+    private final ForecastPowerUltraShortTermStationService forecastPowerUltraShortTermStationService;
+    private final ForecastPowerUltraShortTermCloudService forecastPowerUltraShortTermCloudService;
+    private final ForecastPowerShortTermCloudService forecastPowerShortTermCloudService;
     private final ElectricFieldService electricFieldService;
 //    private final ForecastManufactorService forecastManufactorService;
-    private final ForecastPowerShortTermHisService forecastPowerShortTermHisService;
+    private final ForecastPowerShortTermStationService forecastPowerShortTermStationService;
 
     private final WindTowerStatusDataService windTowerStatusDataService;
 
@@ -42,7 +37,7 @@ public class PowerStationStatusDataServiceImpl extends ServiceImpl<PowerStationS
 
     private final WeatherStationStatusDataService weatherStationStatusDataService;
 
-    private final NwpService nwpService;
+    private final NwpCloudService nwpCloudService;
 
 
     @Override

+ 3 - 3
cpp-admin/src/main/java/com/cpp/web/utils/EfileUtil.java → cpp-admin/src/main/java/com/cpp/web/utils/ParsingEfileUtil.java

@@ -7,7 +7,7 @@ import java.io.*;
  * @author tl
  */
 
-public class EfileUtil {
+public class ParsingEfileUtil {
     /**
      * 打开文件,返回String格式的文件内容
      *
@@ -22,7 +22,7 @@ public class EfileUtil {
 
         //将文件转换为UTF-8格式
         try {
-            EfileUtil.transferFile(path);
+            ParsingEfileUtil.transferFile(path);
         } catch (IOException e) {
             throw new Exception("文件转换为UTF-8格式中出错");
         }
@@ -206,7 +206,7 @@ public class EfileUtil {
 
     public static void main(String[] args) {
         File file = new File("D:\\code\\elanguage\\data\\单列式.txt");
-        String encode = EfileUtil.getCharset(file);
+        String encode = ParsingEfileUtil.getCharset(file);
         System.out.println("encode=" + encode);
     }
 

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/utils/FieldUtil.java → cpp-admin/src/main/java/com/cpp/web/utils/ParsingFieldUtil.java

@@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
  * @date 2022-05-11 10:08:21
  */
 @Slf4j
-public class FieldUtil {
+public class ParsingFieldUtil {
 
     //分隔符
     private static final String SEPARATOR = "<=>";

+ 138 - 0
cpp-admin/src/main/java/com/cpp/web/utils/ParsingFileUtil.java

@@ -0,0 +1,138 @@
+package com.cpp.web.utils;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.ResourceUtils;
+
+import java.io.*;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 操作文件工具类
+ *
+ * @author tl
+ * @date 2022-05-11 10:08:21
+ */
+@Slf4j
+public class ParsingFileUtil {
+    /*按⾏读取txt⽂件并返回⼀个List<String>集合
+     *@param path
+     *@return List<String>
+     */
+    public static List<String> getFileContent(File file) throws Exception {
+        String encodingType = ParsingEfileUtil.getCharset(file);
+        List<String> strList = new ArrayList();
+
+        InputStreamReader inputStreamReader = null;
+        BufferedReader bufferedReader = null;
+        FileInputStream fileInputStream = null;
+        try {
+            fileInputStream = new FileInputStream(file);
+            //将字节流向字符流转换
+            inputStreamReader = new InputStreamReader(fileInputStream, encodingType);
+            //创建字符流缓冲区
+            bufferedReader = new BufferedReader(inputStreamReader);
+            String line;
+            //按⾏读取
+            while ((line = bufferedReader.readLine()) != null) {
+                strList.add(line);
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bufferedReader != null) {
+                try {
+                    bufferedReader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (inputStreamReader != null) {
+                try {
+                    inputStreamReader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fileInputStream != null) {
+                try {
+                    fileInputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return strList;
+        }
+    }
+
+
+    public static String getParsingPath() {
+        return createParsingDir("parsing");
+    }
+
+//    public static String getSendJyDataPath() {
+//        return createParsingDir("ftp");
+//    }
+
+    private static String createParsingDir(String dir) {
+        String path = "/home/syjy/ipp/" + dir;
+        return path;
+    }
+
+    /**
+     * 获取项目根路径
+     *
+     * @return
+     */
+    public static String getResourceBasePath() {
+        // 获取跟目录
+        File path = null;
+        try {
+            path = new File(ResourceUtils.getURL("classpath:").getPath());
+
+        } catch (FileNotFoundException e) {
+            // nothing to do
+        }
+        if (path == null || !path.exists()) {
+            path = new File("");
+        }
+
+        String pathStr = path.getAbsolutePath();
+        try {
+            pathStr = URLDecoder.decode(pathStr, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        // 如果是在eclipse中运行,则和target同级目录,如果是jar部署到服务器,则默认和jar包同级
+//    pathStr = pathStr.replace("\\target\\classes", "");
+
+        return pathStr;
+    }
+
+
+    //把一个文件中的内容读取成一个String字符串
+    public static String getStr(File jsonFile){
+        String jsonStr = "";
+        try {
+            FileReader fileReader = new FileReader(jsonFile);
+            Reader reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8");
+            int ch = 0;
+            StringBuffer sb = new StringBuffer();
+            while ((ch = reader.read()) != -1) {
+                sb.append((char) ch);
+            }
+            fileReader.close();
+            reader.close();
+            jsonStr = sb.toString();
+            return jsonStr;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+}

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/utils/PUtil.java → cpp-admin/src/main/java/com/cpp/web/utils/ParsingUtil.java

@@ -9,7 +9,7 @@ import java.util.List;
  * @author tl
  * @date 2022-05-11 10:08:21
  */
-public class PUtil {
+public class ParsingUtil {
 
 
     /**