소스 검색

Merge branch 'master' of http://git.jiayuepowertech.com:9022/xusl/focus

xiuwei 3 년 전
부모
커밋
e974f48a22
100개의 변경된 파일2486개의 추가작업 그리고 3287개의 파일을 삭제
  1. 2 2
      ipfcst-client/focus-client.yml
  2. 161 0
      ipfcst-client/pom.xml
  3. 17 0
      ipfcst-client/src/main/java/com/jiayue/client/IpfcstClientApplication.java
  4. 7 5
      ipfcst-client/src/main/java/com/jiayue/client/controller/BackDatasController.java
  5. 10 8
      ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java
  6. 7 7
      ipfcst-client/src/main/java/com/jiayue/client/job/SendDataToDcJob.java
  7. 35 43
      ipfcst-client/src/main/java/com/jiayue/client/service/QueryDataService.java
  8. 6 4
      ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java
  9. 0 21
      ipfcst-client/src/main/java/com/jiayue/client/util/FileUtil.java
  10. 8 8
      ipfcst-client/src/main/java/com/jiayue/client/util/MD5Util.java
  11. 14 16
      ipfcst-client/src/main/java/com/jiayue/client/util/Scpclient.java
  12. 42 0
      ipfcst-client/src/main/resources/application.yml
  13. 2 2
      ipfcst-client/src/main/resources/logback-spring.xml
  14. 67 67
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ClassUtil.java
  15. 3 18
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java
  16. 1 4
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CronUtils.java
  17. 11 16
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java
  18. 10 14
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateTimeUtil.java
  19. 1 2
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/JsonBeanUtil.java
  20. 14 13
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ProduceSql.java
  21. 8 15
      ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/SunRiseSet.java
  22. 65 65
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/AbstractBaseEntity.java
  23. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/equipmentstatus/AbstractEquipmentStatusData.java
  24. 7 8
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ChannelDisconLog.java
  25. 1 9
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java
  26. 6 58
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/InverterInfo.java
  27. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomIDGenerator.java
  28. 4 5
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomUUIDGenerator.java
  29. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzBlobTriggersEntity.java
  30. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCalendarsEntity.java
  31. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCronTriggersEntity.java
  32. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzFiredTriggersEntity.java
  33. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzLocksEntity.java
  34. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzPausedTriggerGrpsEntity.java
  35. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSchedulerStateEntity.java
  36. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpleTriggersEntity.java
  37. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpropTriggersEntity.java
  38. 1 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzTriggersEntity.java
  39. 40 46
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/job/BaseJob.java
  40. 2 1
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/DataPointRepository.java
  41. 19 18
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/E63UploadFileRuleService.java
  42. 2 2
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/IUploadFileRuleService.java
  43. 2 2
      ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/UploadFileRuleCommonService.java
  44. 74 167
      ipfcst-common/ipfcst-common-data/src/main/java/org/hibernate/cfg/PropertyContainer.java
  45. 1 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SecurityAuthorizeConfigurerProvider.java
  46. 7 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SysAuthorizeConfigurerManager.java
  47. 0 8
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SystemAuthorizeConfigurerProvider.java
  48. 4 4
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/filter/JwtAuthenticationTokenFilter.java
  49. 9 13
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationFailureHandler.java
  50. 8 6
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationSuccessHandler.java
  51. 4 18
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/JwtUserDetailsServiceImpl.java
  52. 6 3
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/SysUserService.java
  53. 1 20
      ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/util/JwtTokenUtil.java
  54. 5 1
      ipfcst-console/pom.xml
  55. 409 459
      ipfcst-console/src/main/frontend/views/console/inverterInfo/index.vue
  56. 6 0
      ipfcst-console/src/main/frontend/views/console/weatherStationInfo/index.vue
  57. 0 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/config/RedisConfig.java
  58. 17 348
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ElectricFieldController.java
  59. 1 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/FileAnalysisRecordController.java
  60. 2 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerShortTermController.java
  61. 1 4
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerShortTermHisController.java
  62. 2 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerUltraShortTermHisController.java
  63. 103 103
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/InverterInfoController.java
  64. 10 21
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/InverterStatusDataController.java
  65. 2 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/NwpController.java
  66. 0 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/OverHaulOlanController.java
  67. 107 106
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PvModuleModelController.java
  68. 1 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/QuartzController.java
  69. 87 87
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/SysParameterController.java
  70. 89 89
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WeatherStationInfoController.java
  71. 9 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WeatherStationStatusDataController.java
  72. 74 71
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTowerInfoController.java
  73. 8 15
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTowerStatusDataController.java
  74. 5 7
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTurbineInfoController.java
  75. 23 23
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTurbineStatusDataController.java
  76. 0 44
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/dto/ResponseResults.java
  77. 0 30
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/dto/ResponseRows.java
  78. 8 10
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/FileAnalysisJob.java
  79. 3 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/ReceiveDataJob.java
  80. 2 1
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DataPointService.java
  81. 0 2
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/DownLoadService.java
  82. 5 86
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerShortTermHisService.java
  83. 10 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerShortTermService.java
  84. 29 42
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java
  85. 4 34
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/HolidayCalendarService.java
  86. 2 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InitJobClassService.java
  87. 148 194
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InverterInfoService.java
  88. 10 103
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InverterStatusDataService.java
  89. 75 181
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java
  90. 9 13
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/OverHaulPlanService.java
  91. 68 69
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PvModuleModelService.java
  92. 7 3
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzJobFactory.java
  93. 9 23
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzService.java
  94. 196 80
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveDataService.java
  95. 81 90
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysParameterService.java
  96. 5 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationInfoService.java
  97. 33 35
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationStatusDataService.java
  98. 5 8
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerInfoService.java
  99. 9 9
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTowerStatusDataService.java
  100. 107 108
      ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineInfoService.java

+ 2 - 2
focus-client.yml → ipfcst-client/focus-client.yml

@@ -1,6 +1,6 @@
 #青海client小程序使用jar包外配置文件
 remote:
-  ip: 192.168.1.208
+  ip: 192.168.26.32
   port: 22
   user: root
   pwd: Syjy*3377
@@ -10,4 +10,4 @@ v3cloud:
   filelogUrl: https://117.78.19.70:9010/client/getDownLoadFileAll/
   fileDownUrl: https://117.78.19.70:9010/client/getFileById?id=
 local:
-  downFilePath: /Users/wangtao/Documents/temp/client/
+  downFilePath: /home/syjy/ipfcstV3/downLoadFile/

+ 161 - 0
ipfcst-client/pom.xml

@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.5.4</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.jiayue</groupId>
+    <artifactId>ipfcst-client</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>ipfcst-client</name>
+    <description>ipfcst-client</description>
+    <properties>
+        <java.version>1.8</java.version>
+        <spring-boot-admin.version>2.4.3</spring-boot-admin.version>
+        <hutool.version>5.7.13</hutool.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-quartz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>de.codecentric</groupId>
+            <artifactId>spring-boot-admin-starter-client</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!--hutool-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>${hutool.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.ethz.ganymed</groupId>
+            <artifactId>ganymed-ssh2</artifactId>
+            <version>build210</version>
+        </dependency>
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>de.codecentric</groupId>
+                <artifactId>spring-boot-admin-dependencies</artifactId>
+                <version>${spring-boot-admin.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <finalName>focus-client</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.9.1</version>
+                <executions>
+                    <execution>
+                        <id>timestamp-property</id>
+                        <goals>
+                            <goal>timestamp-property</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <name>current.time</name>
+                    <pattern>yyyy-MM-dd HH:mm:ss</pattern>
+                    <timeZone>GMT+8</timeZone>
+                </configuration>
+            </plugin>
+            <!-- jar运行配置 -->
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <!-- main 入口 -->
+                    <mainClass>com.jiayue.client.IpfcstClientApplication</mainClass>
+                    <!-- 设置为ZIP,此模式下spring-boot-maven-plugin会将Manifest.MF文件中的Main-Class设置为org.springframework.boot.loader.PropertiesLauncher -->
+                    <layout>ZIP</layout>
+                    <!-- 需要包含的jar包 -->
+                    <includes>
+                        <!-- 不包含任何jar包 -->
+                        <include>
+                            <groupId>nothing</groupId>
+                            <artifactId>nothing</artifactId>
+                        </include>
+                    </includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>build-info</goal>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- third-party jar into lib directory -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                            <!-- 需要排除的jar的 groupId
+                            <excludeGroupIds>
+                                com.bdfint.logistics
+                            </excludeGroupIds>-->
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 17 - 0
ipfcst-client/src/main/java/com/jiayue/client/IpfcstClientApplication.java

@@ -0,0 +1,17 @@
+package com.jiayue.client;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableScheduling
+@Slf4j
+public class IpfcstClientApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(IpfcstClientApplication.class, args);
+    }
+
+}

+ 7 - 5
ipfcst-client/src/main/java/com/jiayue/client/controller/BackDatasController.java

@@ -3,7 +3,6 @@ package com.jiayue.client.controller;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.client.service.SendDataService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -18,15 +17,18 @@ import java.util.Map;
 @Slf4j
 public class BackDatasController {
 
-    @Autowired
-    public SendDataService sendDataService;
+    public final SendDataService sendDataService;
+
+    public BackDatasController(SendDataService sendDataService) {
+        this.sendDataService = sendDataService;
+    }
 
     @RequestMapping("/send")
     public String sendToDc(String startTime, String endTime, String flag) {
-    
+
         sendDataService.send(startTime, endTime, flag);
 
-        Map result = new HashMap();
+        Map<String, Object> result = new HashMap<>();
         result.put("code", 200);
         result.put("msg", "发送结束");
         return JSONUtil.toJsonStr(result);

+ 10 - 8
ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java

@@ -11,7 +11,6 @@ import com.jiayue.client.service.QueryDataService;
 import com.jiayue.client.util.FileUtil;
 import com.jiayue.client.util.Scpclient;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
 import org.springframework.core.io.PathResource;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -31,12 +30,11 @@ import java.util.Properties;
 @Slf4j
 public class DownloadFileJob {
 
-    @Autowired
-    public QueryDataService queryDataService;
+    public final QueryDataService queryDataService;
     //获取下载到文件,从临时目录移动到目标目录
-    public static List<String> filedownLoadList = new ArrayList<String>();
-    public static List<String> isDownFileId = new ArrayList<String>();
-    public static Properties properties = new Properties();
+    public static List<String> filedownLoadList = new ArrayList<>();
+    public static List<String> isDownFileId = new ArrayList<>();
+    public static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -44,10 +42,14 @@ public class DownloadFileJob {
         properties = yaml.getObject();
     }
 
+    public DownloadFileJob(QueryDataService queryDataService) {
+        this.queryDataService = queryDataService;
+    }
+
     /**
      * 每天凌晨2点执行
      */
-    @Scheduled(cron = "0 0/2 * * * ?")
+    @Scheduled(cron = "0 0/5 * * * ?")
     public void download() {
         log.info("上午文件下载定时任务开始");
         List<Map<String, Object>> stations = queryDataService.getStations();
@@ -71,7 +73,7 @@ public class DownloadFileJob {
                         }
                         log.info("开始下载文件:{}。", fileCreateLog.getFileName());
                         String url = properties.getProperty("v3cloud.fileDownUrl") + fileCreateLog.getId();// "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
-                        Long size = HttpUtil.downloadFile(url, path + File.separatorChar + fileCreateLog.getFileName());
+                        long size = HttpUtil.downloadFile(url, path + File.separatorChar + fileCreateLog.getFileName());
                         if (size > 0) {
                             isDownFileId.add(fileCreateLog.getId());
                             log.info("成功下载文件:{}", path + File.separatorChar + fileCreateLog.getFileName());

+ 7 - 7
ipfcst-client/src/main/java/com/jiayue/client/job/SendDataToDcJob.java

@@ -2,7 +2,6 @@ package com.jiayue.client.job;
 
 import com.jiayue.client.service.SendDataService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -19,10 +18,13 @@ import java.util.Date;
 @Slf4j
 public class SendDataToDcJob {
 
-    @Autowired
-    public SendDataService sendDataService;
+    public final SendDataService sendDataService;
     public static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
+    public SendDataToDcJob(SendDataService sendDataService) {
+        this.sendDataService = sendDataService;
+    }
+
 
     /**
      * 每天凌晨2点执行
@@ -47,8 +49,7 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 0);
         date.set(Calendar.MILLISECOND, 0);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        String dateString = formatter.format(date.getTime());
-        return dateString;
+        return formatter.format(date.getTime());
     }
 
     /**
@@ -64,7 +65,6 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 59);
         date.set(Calendar.MILLISECOND, 999);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        String dateString = formatter.format(date.getTime());
-        return dateString;
+        return formatter.format(date.getTime());
     }
 }

+ 35 - 43
ipfcst-client/src/main/java/com/jiayue/client/service/QueryDataService.java

@@ -1,7 +1,6 @@
 package com.jiayue.client.service;
 
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Repository;
 
@@ -14,8 +13,24 @@ import java.util.Map;
 @Repository
 @Slf4j
 public class QueryDataService {
-    @Autowired
-    private JdbcTemplate jdbcTemplate;
+    private final JdbcTemplate jdbcTemplate;
+
+    public QueryDataService(JdbcTemplate jdbcTemplate) {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    public static Long changStrTimeToLongTime(String strTime) {
+        long resultTime = -1L;
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //设置要读取的时间字符串格式
+        try {
+            Date date = format.parse(strTime);
+            resultTime = date.getTime();
+        } catch (ParseException e) {
+            log.error("转换时间 {} 为Long格式出错:{}", strTime, e);
+        }
+        return resultTime;
+    }
 
     /**
      * 查询所有电站信息
@@ -23,8 +38,8 @@ public class QueryDataService {
     public List<Map<String, Object>> getStations() {
         String stationsSql = "SELECT C_STATION_CODE,C_NAME,C_CAPACITY " +
                 "from t_electric_field ";
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(stationsSql);
-        return list;
+        return jdbcTemplate.queryForList(stationsSql);
+
     }
 
     /**
@@ -40,8 +55,7 @@ public class QueryDataService {
                 "from t_power_station_status_data where C_STATION_CODE='" + stationCode +
                 "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("实际功率回传数据查询sql:{}", rpsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(rpsSql);
-        return list;
+        return jdbcTemplate.queryForList(rpsSql);
     }
 
     /**
@@ -58,8 +72,7 @@ public class QueryDataService {
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
                 "'and '" + changStrTimeToLongTime(endTime) + "'";
         log.info("短期回传数据查询sql:{}", dqsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(dqsSql);
-        return list;
+        return jdbcTemplate.queryForList(dqsSql);
     }
 
     /**
@@ -76,8 +89,7 @@ public class QueryDataService {
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
                 "'and '" + changStrTimeToLongTime(endTime) + "'";
         log.info("超短期回传数据查询sql:{}", cdqsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(cdqsSql);
-        return list;
+        return jdbcTemplate.queryForList(cdqsSql);
     }
 
     /**
@@ -89,11 +101,10 @@ public class QueryDataService {
      * @return
      */
     public List<Map<String, Object>> getWeatherds(String startTime, String endTime, String equirpmentNo) {
-        String wedSql = "SELECT C_TIME,C_EQUIPMENT_NO,C_GLOBALR,C_AIRT " +
-                "from t_weather_station_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+        String wedSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_GLOBALR,C_AIRT " +
+                "from t_weather_station_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("超短期回传数据查询sql:{}", wedSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(wedSql);
-        return list;
+        return jdbcTemplate.queryForList(wedSql);
     }
 
     /**
@@ -105,12 +116,11 @@ public class QueryDataService {
      * @return
      */
     public List<Map<String, Object>> getCfts(String startTime, String endTime, String equirpmentNo) {
-        String cftsSql = "SELECT C_TIME,C_EQUIPMENT_NO,C_WS_INST_HUB_HEIGHT,C_WD_INST_HUB_HEIGHT " +
-                "from t_wind_tower_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+        String cftsSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_WS_INST_HUB_HEIGHT,C_WD_INST_HUB_HEIGHT " +
+                "from t_wind_tower_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("测风塔回传数据查询sql:{}", cftsSql);
 
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(cftsSql);
-        return list;
+        return jdbcTemplate.queryForList(cftsSql);
     }
 
     /**
@@ -122,25 +132,10 @@ public class QueryDataService {
      * @return
      */
     public List<Map<String, Object>> getFjs(String startTime, String endTime, String equirpmentNo) {
-        String fjsSql = "SELECT C_TIME,C_EQUIPMENT_NO,C_WS,C_WD " +
-                "from t_wind_turbine_status_data where C_EQUIPMENT_NO='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+        String fjsSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_WS,C_WD " +
+                "from t_wind_turbine_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
         log.info("风机回传数据查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
-    }
-
-
-    public static Long changStrTimeToLongTime(String strTime) {
-        Long resultTime = -1L;
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//设置要读取的时间字符串格式
-        try {
-            Date date = format.parse(strTime);
-            resultTime = date.getTime();
-        } catch (ParseException e) {
-            log.error("转换时间 {} 为Long格式出错:{}", strTime, e);
-        }
-        return resultTime;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -153,8 +148,7 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_weather_station_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("环境检测仪设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -167,8 +161,7 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_wind_tower_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("测风塔设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 
     /**
@@ -181,7 +174,6 @@ public class QueryDataService {
         String fjsSql = "SELECT C_ID,C_EQUIPMENT_NO,C_EQUIPMENT_TYPE " +
                 "from t_wind_turbine_info where C_STATION_CODE='" + stationCode + "' ";
         log.info("风机设备信息查询sql:{}", fjsSql);
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(fjsSql);
-        return list;
+        return jdbcTemplate.queryForList(fjsSql);
     }
 }

+ 6 - 4
ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java

@@ -5,7 +5,6 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
 import com.jiayue.client.util.MD5Util;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
 import org.springframework.core.io.PathResource;
 import org.springframework.stereotype.Repository;
@@ -15,12 +14,11 @@ import java.util.*;
 @Repository
 @Slf4j
 public class SendDataService {
-    @Autowired
-    public QueryDataService queryDataService;
+    public final QueryDataService queryDataService;
     //青海回传数据通用签名key
     private final static String qinghaiKey = "Syjy*3377";
 
-    public static Properties properties = new Properties();
+    public static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -28,6 +26,10 @@ public class SendDataService {
         properties = yaml.getObject();
     }
 
+    public SendDataService(QueryDataService queryDataService) {
+        this.queryDataService = queryDataService;
+    }
+
     /**
      * 向数据中心
      *

+ 0 - 21
ipfcst-client/src/main/java/com/jiayue/client/util/FileUtil.java

@@ -6,24 +6,6 @@ import java.io.File;
 
 @Slf4j
 public class FileUtil {
-    public static void mvFile(String fsPath, String fdPath) {
-//        File fs = new File("D:\\迅雷下载\\f31.mp4");
-//        File fd = new File("D:\\");
-        //源文件
-        File fs = new File(fsPath);
-        //目标目录
-        File fd = new File(fdPath);
-        //判断目标目录是否存在同名文件,存在则删除
-        File md = new File(fdPath + fs.getName());
-        if (md.exists()) {
-            md.delete();
-        }
-        try {
-            fs.renameTo(fd);
-        } catch (Exception e) {
-            log.error("文件移动错误", e);
-        }
-    }
 
     public static String judeDirExists(String path) {
         try {
@@ -48,9 +30,6 @@ public class FileUtil {
                 }
                 file.mkdir();
 
-                /*if (osName.indexOf("Windows") <= -1) {
-                    Runtime.getRuntime().exec("chmod 777 -R " + path);//ftp服务器在linux环境中,生成的文件涉及到读写权限问题,直接给777权限
-                }*/
             }
             log.info("path:" + path);
         } catch (Exception e) {

+ 8 - 8
ipfcst-client/src/main/java/com/jiayue/client/util/MD5Util.java

@@ -16,7 +16,7 @@ public class MD5Util {
     }
 
     public static String encode(String str) {
-        MessageDigest md5 = null;
+        MessageDigest md5;
         try {
             md5 = MessageDigest.getInstance("MD5");
         } catch (Exception e) {
@@ -30,9 +30,9 @@ public class MD5Util {
         }
 
         byte[] md5Bytes = md5.digest(byteArray);
-        StringBuffer hexValue = new StringBuffer();
-        for (int i = 0; i < md5Bytes.length; i++) {
-            int val = ((int) md5Bytes[i]) & 0xff;
+        StringBuilder hexValue = new StringBuilder();
+        for (byte md5Byte : md5Bytes) {
+            int val = ((int) md5Byte) & 0xff;
             if (val < 16) {
                 hexValue.append("0");
             }
@@ -53,13 +53,13 @@ public class MD5Util {
         try {
             MessageDigest md = MessageDigest.getInstance(encryption);
             md.update(plainText.getBytes());
-            byte b[] = md.digest();
+            byte[] b = md.digest();
 
             int i;
 
-            StringBuffer buf = new StringBuffer("");
-            for (int offset = 0; offset < b.length; offset++) {
-                i = b[offset];
+            StringBuilder buf = new StringBuilder();
+            for (byte value : b) {
+                i = value;
                 if (i < 0)
                     i += 256;
                 if (i < 16)

+ 14 - 16
ipfcst-client/src/main/java/com/jiayue/client/util/Scpclient.java

@@ -12,6 +12,17 @@ import java.util.Map;
 @Slf4j
 public class Scpclient {
     static private Scpclient instance;
+    private final String ip;
+    private int port;
+    private String username;
+    private String password;
+
+    public Scpclient(String ip, int port, String username, String passward) {
+        this.ip = ip;
+        this.port = port;
+        this.username = username;
+        this.password = passward;
+    }
 
     static synchronized public Scpclient getInstance(String IP, int port,
                                                      String username, String passward) {
@@ -21,13 +32,6 @@ public class Scpclient {
         return instance;
     }
 
-    public Scpclient(String IP, int port, String username, String passward) {
-        this.ip = IP;
-        this.port = port;
-        this.username = username;
-        this.password = passward;
-    }
-
     /**
      * 远程拷贝文件
      *
@@ -40,7 +44,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
                 return null;
             }
@@ -54,7 +58,6 @@ public class Scpclient {
         return null;
     }
 
-
     /**
      * 远程上传文件
      *
@@ -67,7 +70,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
             }
             SCPClient client = new SCPClient(conn);
@@ -93,7 +96,7 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (isAuthenticated == false) {
+            if (!isAuthenticated) {
                 log.info("authentication failed");
             }
             SCPClient client = new SCPClient(conn);
@@ -114,11 +117,6 @@ public class Scpclient {
         }
     }
 
-    private String ip;
-    private int port;
-    private String username;
-    private String password;
-
     public String getUsername() {
         return username;
     }

+ 42 - 0
ipfcst-client/src/main/resources/application.yml

@@ -0,0 +1,42 @@
+server:
+  port: 81
+spring:
+  thymeleaf:
+    mode: HTML5
+    encoding: UTF-8
+    servlet:
+      content-type: text/html
+    cache: false
+    tomcat:
+      uri-encoding: UTF-8
+      max-connections: 200000
+      max-http-form-post-size: 9000000
+      threads:
+        max: 128
+        min-spare: 5
+    #mysql
+  datasource:
+    url: jdbc:mysql://192.168.35.43:3306/focus?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+    username: root
+    password: '!QAZ2root'
+logging:
+  config: classpath:logback-spring.xml
+
+management:
+  endpoints:
+    web:
+      exposure:
+        include: [ "health", "logfile","info" ]
+      base-path: /ipfcst-client
+  endpoint:
+    logfile:
+      enabled: true
+      external-file: logs/client-debug.log
+    health:
+      show-details: always
+info:
+  app.name: qinghai-client
+  app.time: @current.time@
+  app.version: v1
+
+

+ 2 - 2
ipfcst-client/src/main/resources/logback-spring.xml

@@ -22,7 +22,7 @@
 
     <!-- Log file debug output -->
     <appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/client.log</file>
+        <file>${log.path}/client-debug.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
             <maxFileSize>50MB</maxFileSize>
@@ -35,7 +35,7 @@
 
     <!-- Log file error output -->
     <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${log.path}/error.log</file>
+        <file>${log.path}/client-error.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
             <maxFileSize>50MB</maxFileSize>

+ 67 - 67
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ClassUtil.java

@@ -21,76 +21,76 @@ import java.lang.reflect.Method;
  */
 @UtilityClass
 public class ClassUtil extends ClassUtils {
-	private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
+    private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
 
-	/**
-	 * 获取方法参数信息
-	 *
-	 * @param constructor    构造器
-	 * @param parameterIndex 参数序号
-	 * @return {MethodParameter}
-	 */
-	public MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
-		MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex);
-		methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
-		return methodParameter;
-	}
+    /**
+     * 获取方法参数信息
+     *
+     * @param constructor    构造器
+     * @param parameterIndex 参数序号
+     * @return {MethodParameter}
+     */
+    public MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
+        MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex);
+        methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
+        return methodParameter;
+    }
 
-	/**
-	 * 获取方法参数信息
-	 *
-	 * @param method         方法
-	 * @param parameterIndex 参数序号
-	 * @return {MethodParameter}
-	 */
-	public MethodParameter getMethodParameter(Method method, int parameterIndex) {
-		MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex);
-		methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
-		return methodParameter;
-	}
+    /**
+     * 获取方法参数信息
+     *
+     * @param method         方法
+     * @param parameterIndex 参数序号
+     * @return {MethodParameter}
+     */
+    public MethodParameter getMethodParameter(Method method, int parameterIndex) {
+        MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex);
+        methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
+        return methodParameter;
+    }
 
-	/**
-	 * 获取Annotation
-	 *
-	 * @param method         Method
-	 * @param annotationType 注解类
-	 * @param <A>            泛型标记
-	 * @return {Annotation}
-	 */
-	public <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
-		Class<?> targetClass = method.getDeclaringClass();
-		// The method may be on an interface, but we need attributes from the target class.
-		// If the target class is null, the method will be unchanged.
-		Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
-		// If we are dealing with method with generic parameters, find the original method.
-		specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
-		// 先找方法,再找方法上的类
-		A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType);
-		;
-		if (null != annotation) {
-			return annotation;
-		}
-		// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
-		return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType);
-	}
+    /**
+     * 获取Annotation
+     *
+     * @param method         Method
+     * @param annotationType 注解类
+     * @param <A>            泛型标记
+     * @return {Annotation}
+     */
+    public <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
+        Class<?> targetClass = method.getDeclaringClass();
+        // The method may be on an interface, but we need attributes from the target class.
+        // If the target class is null, the method will be unchanged.
+        Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
+        // If we are dealing with method with generic parameters, find the original method.
+        specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
+        // 先找方法,再找方法上的类
+        A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType);
 
-	/**
-	 * 获取Annotation
-	 *
-	 * @param handlerMethod  HandlerMethod
-	 * @param annotationType 注解类
-	 * @param <A>            泛型标记
-	 * @return {Annotation}
-	 */
-	public <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
-		// 先找方法,再找方法上的类
-		A annotation = handlerMethod.getMethodAnnotation(annotationType);
-		if (null != annotation) {
-			return annotation;
-		}
-		// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
-		Class<?> beanType = handlerMethod.getBeanType();
-		return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType);
-	}
+        if (null != annotation) {
+            return annotation;
+        }
+        // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
+        return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType);
+    }
+
+    /**
+     * 获取Annotation
+     *
+     * @param handlerMethod  HandlerMethod
+     * @param annotationType 注解类
+     * @param <A>            泛型标记
+     * @return {Annotation}
+     */
+    public <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
+        // 先找方法,再找方法上的类
+        A annotation = handlerMethod.getMethodAnnotation(annotationType);
+        if (null != annotation) {
+            return annotation;
+        }
+        // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
+        Class<?> beanType = handlerMethod.getBeanType();
+        return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType);
+    }
 
 }

+ 3 - 18
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CommonUtil.java

@@ -22,7 +22,6 @@ public abstract class CommonUtil {
 
     private static final int BUFFER_SIZE = 2 * 1024;
     public static Properties props = System.getProperties();
-    public static String osName = props.getProperty("os.name");
 
     /**
      * 获取随机数
@@ -57,21 +56,9 @@ public abstract class CommonUtil {
 
         List<File> list = getFiles(path, new ArrayList<>());
 
-        if (list != null && list.size() > 0) {
+        if (list.size() > 0) {
 
-            Collections.sort(list, new Comparator<File>() {
-                @Override
-                public int compare(File file, File newFile) {
-                    if (file.lastModified() < newFile.lastModified()) {
-                        return 1;
-                    } else if (file.lastModified() == newFile.lastModified()) {
-                        return 0;
-                    } else {
-                        return -1;
-                    }
-
-                }
-            });
+            list.sort((file, newFile) -> Long.compare(newFile.lastModified(), file.lastModified()));
 
         }
 
@@ -89,9 +76,7 @@ public abstract class CommonUtil {
 
         File realFile = new File(realpath);
         File[] subfiles = realFile.listFiles();
-        for (File file : subfiles) {
-            files.add(file);
-        }
+        Collections.addAll(files, Objects.requireNonNull(subfiles));
         return files;
     }
 

+ 1 - 4
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/CronUtils.java

@@ -67,8 +67,6 @@ public class CronUtils {
         Date time2 = trigger.getFireTimeAfter(time1);
         Date time3 = trigger.getFireTimeAfter(time2);
         long l = time1.getTime() - (time3.getTime() - time2.getTime());
-//		Date date = new Date(l);
-//		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date date = new Date();
         date.setTime(l);
         return date;
@@ -83,7 +81,6 @@ public class CronUtils {
     public static Date getNextTriggerTime(String cron) {
         CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("Caclulate Date").withSchedule(CronScheduleBuilder.cronSchedule(cron)).build();
         Date time0 = trigger.getStartTime();
-        Date time1 = trigger.getFireTimeAfter(time0);
-        return time1;
+        return trigger.getFireTimeAfter(time0);
     }
 }

+ 11 - 16
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java

@@ -56,12 +56,10 @@ public abstract class DateMomentUtil {
         int moment = DateMomentUtil.getMoment(dateTime, momentLength);// 获取指定时间所在时刻数
         long differentTime = moment * momentLength;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
-        switch (signType) {
-            case 2:
-                return dayStartTime + differentTime;
-            default:
-                return dayStartTime + differentTime - momentLength;
+        if (signType == 2) {
+            return dayStartTime + differentTime;
         }
+        return dayStartTime + differentTime - momentLength;
     }
 
     /**
@@ -79,12 +77,10 @@ public abstract class DateMomentUtil {
         if (24 * 3600 * 1000L % momentLength != 0)
             throw new Exception("时刻长度非法,时刻长度需要能够被一天整除");
         long dayStartTime = DateMomentUtil.getDayStartTime(dateTime);
-        switch (signType) {
-            case 2:
-                return dayStartTime + momentLength;
-            default:
-                return dayStartTime;
+        if (signType == 2) {
+            return dayStartTime + momentLength;
         }
+        return dayStartTime;
     }
 
     /**
@@ -108,12 +104,10 @@ public abstract class DateMomentUtil {
         date.set(Calendar.MINUTE, 0);
         date.set(Calendar.SECOND, 0);
         date.set(Calendar.MILLISECOND, 0);
-        switch (signType) {
-            case 2:
-                return date.getTimeInMillis();
-            default:
-                return date.getTimeInMillis() - momentLength;
+        if (signType == 2) {
+            return date.getTimeInMillis();
         }
+        return date.getTimeInMillis() - momentLength;
     }
 
     /**
@@ -150,8 +144,9 @@ public abstract class DateMomentUtil {
 
     /**
      * 获取两个时间间的间隔天数(自然天)
+     *
      * @param dateFrom 开始时间
-     * @param dateTo 结束时间
+     * @param dateTo   结束时间
      * @return 自然天数
      */
     public static Integer getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {

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

@@ -8,6 +8,7 @@ import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * 时间工具类
@@ -65,7 +66,7 @@ public class DateTimeUtil {
      */
     public static Date getMomentTimeFor15Minute(@NotNull final Long dateTime) {
         int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
-        long differentTime = moment * 15 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long differentTime = (long) moment * 15 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
         return new Date(dayStartTime + differentTime - 15 * 60 * 1000);
     }
@@ -80,7 +81,7 @@ public class DateTimeUtil {
      */
     public static Date getMomentTimeFor5Minute(@NotNull final Long dateTime) {
         int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
-        long differentTime = moment * 5 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long differentTime = (long) moment * 5 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
         long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
         return new Date(dayStartTime + differentTime - 5 * 60 * 1000);
     }
@@ -172,8 +173,7 @@ public class DateTimeUtil {
     public static String getStringDate() {
         Date currentTime = new Date();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String dateString = formatter.format(currentTime);
-        return dateString;
+        return formatter.format(currentTime);
     }
 
     /**
@@ -184,8 +184,7 @@ public class DateTimeUtil {
      */
     public static String dateToStrLong(Date dateDate) {
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String dateString = formatter.format(dateDate);
-        return dateString;
+        return formatter.format(dateDate);
     }
 
     /**
@@ -197,8 +196,7 @@ public class DateTimeUtil {
     public static Date strToDateLongHM(String strDate) {
         SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
         ParsePosition pos = new ParsePosition(0);
-        Date strtodate = formatter.parse(strDate, pos);
-        return strtodate;
+        return formatter.parse(strDate, pos);
     }
 
     /**
@@ -225,17 +223,14 @@ public class DateTimeUtil {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        if (dt1.getTime() > dt2.getTime() && dt1.getTime() < dt3.getTime()) {
-            return true;
-        } else {
-            return false;
-        }
+        return Objects.requireNonNull(dt1).getTime() > Objects.requireNonNull(dt2).getTime() && dt1.getTime() < Objects.requireNonNull(dt3).getTime();
     }
 
     /**
      * 判断时间是不是今天
+     *
      * @param date
-     * @return    是返回true,不是返回false
+     * @return 是返回true,不是返回false
      */
     public static boolean isNow(Date date) {
         //当前时间
@@ -250,6 +245,7 @@ public class DateTimeUtil {
 
     /**
      * 将时间戳秒变成0
+     *
      * @param dateTime
      * @return
      */

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

@@ -23,8 +23,7 @@ public class JsonBeanUtil {
      */
     public static <T> List<T> jsonToBean(String json, Class<T> t) {
         JSONArray array = JSONUtil.parseArray(json);
-        List<T> list = array.toList(t);
-        return list;
+        return array.toList(t);
     }
 
     /**

+ 14 - 13
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/ProduceSql.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 
 import java.lang.reflect.Field;
+import java.util.Objects;
 
 /**
  * TODO
@@ -22,7 +23,7 @@ public class ProduceSql {
     public static <T> String getInsertSql(String tablename, T t) throws IllegalArgumentException {
         //insert into table_name (column_name1,column_name2, ...) values (value1,value2, ...)
         boolean flag = false;
-        String sql = "";
+        String sql;
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
         StringBuffer topHalf = new StringBuffer("insert into " + tablename + " (");
         StringBuffer afterAalf = new StringBuffer("values (");
@@ -54,7 +55,7 @@ public class ProduceSql {
         afterAalf = new StringBuffer(StrUtil.removeSuffix(afterAalf.toString(), ","));
         topHalf.append(") ");
         afterAalf.append(") ");
-        sql = topHalf.toString() + afterAalf.toString();
+        sql = topHalf + afterAalf.toString();
         return sql;
     }
 
@@ -72,24 +73,24 @@ public class ProduceSql {
         //or
         //UPDATE table_name SET column_name1 = value1, column_name2 = value2, ... where id=xxx
         boolean flag = false;
-        String sql = "";
+        StringBuilder sql;
         String id = ""; //保存id列名:ID or id
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
-        sql = "update " + tablename + " set ";
+        sql = new StringBuilder("update " + tablename + " set ");
         for (Field field : fields) {
             StringBuffer tmp = new StringBuffer();
             if ("ID".equals(field.getName()) || "id".equals(field.getName())) {
                 id = field.getName();
                 continue;//更新的时候无需set id=xxx
             }
-            if (ReflectUtil.getFieldValue(t, field.getName()) != null && (String) ReflectUtil.getFieldValue(t, field.getName()) != "") {
+            if (ReflectUtil.getFieldValue(t, field.getName()) != null && !Objects.equals(ReflectUtil.getFieldValue(t, field.getName()), "")) {
 
                 String underScoreCaseColumn = field.getName();
                 for (int i = 0; i < field.getName().length(); i++) {
                     if (Character.isUpperCase(field.getName().charAt(i)))
                     // 将javabean中小驼峰命名变量的“大写字母”转换为“_小写字母”
                     {
-                        underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1, field.getName().length());
+                        underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1);
                     }
                 }
 
@@ -101,14 +102,14 @@ public class ProduceSql {
                     tmp.append(ReflectUtil.getFieldValue(t, underScoreCaseColumn) + ",");
                     flag = true;
                 }
-                sql += tmp;
+                sql.append(tmp);
             }
         }
         if (!flag) {
             throw new IllegalArgumentException(t.getClass() + "NullException.\nThere is no attribute that is not empty except for ID.You must provide an object with at least one attribute exclude ID.");
         }
-        sql = StrUtil.removeSuffix(sql, ",") + " where " + id + "='" + ReflectUtil.getFieldValue(t, id) + "'";
-        return sql;
+        sql = new StringBuilder(StrUtil.removeSuffix(sql.toString(), ",") + " where " + id + "='" + ReflectUtil.getFieldValue(t, id) + "'");
+        return sql.toString();
     }
 
     /**
@@ -150,16 +151,16 @@ public class ProduceSql {
     private static <T> String getSelectOrDeleteSql(String tablename, T t, String operation) throws IllegalArgumentException {
         //operation from table_name where column_name = value
         boolean flag = false;
-        String sql = "";
+        String sql;
         Field[] fields = ReflectUtil.getFieldsDirectly(t.getClass(), false);
-        StringBuffer topHalf = new StringBuffer(operation + " from " + tablename + " where ");
+        StringBuilder topHalf = new StringBuilder(operation + " from " + tablename + " where ");
         for (Field field : fields) {
             String underScoreCaseColumn = field.getName();
             for (int i = 0; i < field.getName().length(); i++) {
                 if (Character.isUpperCase(field.getName().charAt(i)))
                 // 将javabean中小驼峰命名变量的“大写字母”转换为“_小写字母”
                 {
-                    underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1, field.getName().length());
+                    underScoreCaseColumn = field.getName().substring(0, i) + '_' + field.getName().substring(i, i + 1).toLowerCase() + field.getName().substring(i + 1);
                 }
             }
             if ("ID".equals(underScoreCaseColumn) || "id".equals(underScoreCaseColumn)) {
@@ -170,7 +171,7 @@ public class ProduceSql {
                     break;
                 }
             } else {
-                if (ReflectUtil.getFieldValue(t, underScoreCaseColumn) != null && (String) ReflectUtil.getFieldValue(t, underScoreCaseColumn) != "") {
+                if (ReflectUtil.getFieldValue(t, underScoreCaseColumn) != null && !Objects.equals(ReflectUtil.getFieldValue(t, underScoreCaseColumn), "")) {
                     topHalf.append(underScoreCaseColumn + " = '" + ReflectUtil.getFieldValue(t, underScoreCaseColumn) + "'");
                     flag = true;
                     break;

+ 8 - 15
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/SunRiseSet.java

@@ -3,12 +3,13 @@ package com.jiayue.ipfcst.common.core.util;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Objects;
 
 public class SunRiseSet {
 
-    private static int[] days_of_month_1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+    private static final int[] days_of_month_1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
-    private static int[] days_of_month_2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+    private static final int[] days_of_month_2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
     private final static double h = -0.833;//日出日落时太阳的位置
 
@@ -22,9 +23,7 @@ public class SunRiseSet {
 
     public static boolean leap_year(int year) {
 
-        if (((year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0))) return true;
-
-        else return false;
+        return (year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0);
 
     }
 
@@ -227,9 +226,9 @@ public class SunRiseSet {
 
     public static int Zone(double glong) {
 
-        if (glong >= 0) return (int) ((int) (glong / 15.0) + 1);
+        if (glong >= 0) return (int) (glong / 15.0) + 1;
 
-        else return (int) ((int) (glong / 15.0) - 1);
+        else return (int) (glong / 15.0) - 1;
 
     }
 
@@ -247,7 +246,7 @@ public class SunRiseSet {
             if (m != null && m != "" && m.indexOf("0") == -1) {
                 m = m.replaceAll("0", "");
             }
-            month = Integer.parseInt(m);
+            month = Integer.parseInt(Objects.requireNonNull(m));
 
             date = Integer.parseInt(d);
 
@@ -271,12 +270,6 @@ public class SunRiseSet {
 
                                     G_sun(t_century(days(year, month, date), UTo)))))), UTo, glong, glat, year, month, date);
 
-//System.out.println("Sunrise is: "+(int)(sunrise/15+Zone(glong))+":"+(int)(60*(sunrise/15+Zone(glong)-(int)(sunrise/15+Zone(glong))))+" .\n");
-
-//        Log.d("Sunrise", "Sunrise is: "+(int)(sunrise/15+8)+":"+(int)(60*(sunrise/15+8-(int)(sunrise/15+8)))+" .\n");
-
-            //return "Sunrise is: "+(int)(sunrise/15+Zone(glong))+":"+(int)(60*(sunrise/15+Zone(glong)-(int)(sunrise/15+Zone(glong))))+" .\n";
-
             return (int) (sunrise / 15 + 8) + ":" + (int) (60 * (sunrise / 15 + 8 - (int) (sunrise / 15 + 8)));
         }
         return null;
@@ -297,7 +290,7 @@ public class SunRiseSet {
             if (m != null && m != "" && m.indexOf("0") == -1) {
                 m = m.replaceAll("0", "");
             }
-            month = Integer.parseInt(m);
+            month = Integer.parseInt(Objects.requireNonNull(m));
 
             date = Integer.parseInt(d);
 

+ 65 - 65
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/AbstractBaseEntity.java

@@ -27,79 +27,79 @@ import java.util.Date;
 public
 class AbstractBaseEntity implements Serializable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * 备用字段A
-	 */
-	@Order(200)
-	@Column
-	private String backupA;
+    /**
+     * 备用字段A
+     */
+    @Order(200)
+    @Column
+    private String backupA;
 
-	/**
-	 * 备用字段B
-	 */
-	@Order(201)
-	@Column
-	private String backupB;
+    /**
+     * 备用字段B
+     */
+    @Order(201)
+    @Column
+    private String backupB;
 
-	/**
-	 * 备用字段C
-	 */
-	@Order(202)
-	@Column
-	private String backupC;
+    /**
+     * 备用字段C
+     */
+    @Order(202)
+    @Column
+    private String backupC;
 
-	/**
-	 * 备用字段D
-	 */
-	@Order(203)
-	@Column
-	private String backupD;
+    /**
+     * 备用字段D
+     */
+    @Order(203)
+    @Column
+    private String backupD;
 
-	/**
-	 * 备用字段E
-	 */
-	@Order(204)
-	@Column
-	private String backupE;
+    /**
+     * 备用字段E
+     */
+    @Order(204)
+    @Column
+    private String backupE;
 
-	/**
-	 * 备用字段F
-	 */
-	@Order(205)
-	@Column
-	private String backupF;
+    /**
+     * 备用字段F
+     */
+    @Order(205)
+    @Column
+    private String backupF;
 
 
-	/**
-	 * 创建人,不允许修改
-	 */
-	@Order(206)
-	@CreatedBy
-	@Column(updatable = false)
-	private String creator;
+    /**
+     * 创建人,不允许修改
+     */
+    @Order(206)
+    @CreatedBy
+    @Column(updatable = false)
+    private String creator;
 
-	/**
-	 * 创建时间,不允许修改
-	 */
-	@Order(207)
-	@CreatedDate
-	@Column(updatable = true)
-	private Date createTime;
+    /**
+     * 创建时间,不允许修改
+     */
+    @Order(207)
+    @CreatedDate
+    @Column()
+    private Date createTime;
 
-	/**
-	 * 最后修改者
-	 */
-	@Order(208)
-	@LastModifiedBy
-	@Column(insertable = false)
-	private String lastModifier;
-	/**
-	 * 最后修改时间
-	 */
-	@Order(209)
-	@LastModifiedDate
-	@Column(insertable = false)
-	private Date lastModifyTime;
+    /**
+     * 最后修改者
+     */
+    @Order(208)
+    @LastModifiedBy
+    @Column(insertable = false)
+    private String lastModifier;
+    /**
+     * 最后修改时间
+     */
+    @Order(209)
+    @LastModifiedDate
+    @Column(insertable = false)
+    private Date lastModifyTime;
 }

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/abst/equipmentstatus/AbstractEquipmentStatusData.java

@@ -38,7 +38,7 @@ public class AbstractEquipmentStatusData implements Serializable {
 
     /**
      * 状态
-     * 状态值为0代表运行,1代表故障,2代表待机,3代表检修
+     * 状态值为1代表运行,2代表待机,3代表停用,4代表故障
      */
     @Column
     private Integer status = 0;

+ 7 - 8
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ChannelDisconLog.java

@@ -60,16 +60,15 @@ public class ChannelDisconLog extends AbstractBaseEntity {
     /**
      * 计算并配置持续时间
      */
-    public void countAndSetDuration(){
-        if(this.reconnectTime==null || this.disconnectTime==null || this.reconnectTime <= this.disconnectTime){
+    public void countAndSetDuration() {
+        if (this.reconnectTime == null || this.disconnectTime == null || this.reconnectTime <= this.disconnectTime) {
             return;
         }
-        Long durationL = this.reconnectTime-this.disconnectTime;
-        if (durationL/1000>=60){
-            setDuration(durationL/(1000*60)+"分");
-        }
-        else{
-           setDuration(durationL/1000+"秒");
+        long durationL = this.reconnectTime - this.disconnectTime;
+        if (durationL / 1000 >= 60) {
+            setDuration(durationL / (1000 * 60) + "分");
+        } else {
+            setDuration(durationL / 1000 + "秒");
         }
     }
 }

+ 1 - 9
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/ElectricField.java

@@ -20,15 +20,7 @@ import java.math.BigDecimal;
 @Data
 @Entity
 public class ElectricField extends AbstractBaseEntity {
-    /**
-     * 备用字段A(用于所属地调字段)
-     */
-    /**
-     * 备用字段B(站内受阻容量,不需要页面显示)
-     */
-    /**
-     * 备用字段C(用于绿能场站编号)
-     */
+
     /**
      * 场站编号(运维标识,主键)
      */

+ 6 - 58
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/InverterInfo.java

@@ -22,96 +22,44 @@ import java.math.BigDecimal;
 @Entity
 public class InverterInfo extends AbstractEquipmentInfo {
 
-    public InverterInfo() {
-        super.setEquipmentType(EquipmentTypeEnum.INVERTER);
-    }
-    /**
-     * 备用字段A 应用于样板机编号
-     */
     /**
      * 逆变器名称
      */
     @Column
     private String name;
-
+    /**
+     * 备用字段A 应用于样板机编号
+     */
     /**
      * 是否组串式
      */
     @Column
     private Boolean groupSeries;
-
     /**
      * 逆变器效率(%)
      */
     @Digits(integer = 5, fraction = 2)
     @Column
     private BigDecimal efficiency;
-
     /**
      * 额定功率(KW)
      */
     @Digits(integer = 10, fraction = 2)
     @Column
     private BigDecimal capacity;
-
-    /**
-     * 箱式变压器
-     */
-    @Column
-    private String box;
-
     /**
      * 集电线路
      */
     @Column
     private String collectorCircuit;
-
-
-    /**
-     * 光伏组件型号
-     */
-    @Column
-    private String batteryModel;
-
-    /**
-     * 光伏组件数量(个)
-     */
-    @Column
-    private Integer batteryNumber;
-
-    /*   *//**
-     * 光伏阵列的倾斜角(°)
-     *//*
-    @Column
-    private Float pvArrayAngle;
-
-    *//**
-     * 光伏阵列的方位(°),方位角为零。正南为0,正西为90,正北180,正东270
-     *//*
-    @Column
-    private Float pvPosition;
-
-    *//**
-     * 光伏组件旋转方式
-     *//*
-    @Column
-    private PvRotationModeEnum pvRotationModeEnum;
-*/
     /**
      * 逆变器是否样板机
      */
     @Column
     private Boolean sample;
 
-    /**
-     * backupA 样板机编号
-     */
-
-    /**
-     * backupB 经度
-     */
+    public InverterInfo() {
+        super.setEquipmentType(EquipmentTypeEnum.INVERTER);
+    }
 
-    /**
-     * backupC 纬度
-     */
 }

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomIDGenerator.java

@@ -17,7 +17,7 @@ public class CustomIDGenerator extends IdentityGenerator {
     public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
         Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
 
-        if (id != null && Integer.valueOf(id.toString()) > 0) {
+        if (id != null && Integer.parseInt(id.toString()) > 0) {
             return id;
         } else {
             return super.generate(s, obj);

+ 4 - 5
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/id/CustomUUIDGenerator.java

@@ -18,11 +18,10 @@ public class CustomUUIDGenerator extends IdGenerator {
     @Override
     public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
         Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
-        if (id != null && !id.toString().isEmpty()) {
-        } else {
-            id=super.generate(s, obj);
-            log.debug("新生成的uuid="+id.toString());
+        if (id == null || id.toString().isEmpty()) {
+            id = super.generate(s, obj);
+            log.debug("新生成的uuid=" + id.toString());
         }
-	    return id;
+        return id;
     }
 }

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzBlobTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_blob_triggers", catalog = "")
+@Table(name = "qrtz_blob_triggers")
 @IdClass(QrtzBlobTriggersEntityPK.class)
 public class QrtzBlobTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCalendarsEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_calendars", catalog = "")
+@Table(name = "qrtz_calendars")
 @IdClass(QrtzCalendarsEntityPK.class)
 public class QrtzCalendarsEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzCronTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_cron_triggers", catalog = "")
+@Table(name = "qrtz_cron_triggers")
 @IdClass(QrtzCronTriggersEntityPK.class)
 public class QrtzCronTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzFiredTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_fired_triggers", catalog = "")
+@Table(name = "qrtz_fired_triggers")
 @IdClass(QrtzFiredTriggersEntityPK.class)
 public class QrtzFiredTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzLocksEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_locks", catalog = "")
+@Table(name = "qrtz_locks")
 @IdClass(QrtzLocksEntityPK.class)
 public class QrtzLocksEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzPausedTriggerGrpsEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_paused_trigger_grps", catalog = "")
+@Table(name = "qrtz_paused_trigger_grps")
 @IdClass(QrtzPausedTriggerGrpsEntityPK.class)
 public class QrtzPausedTriggerGrpsEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSchedulerStateEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_scheduler_state", catalog = "")
+@Table(name = "qrtz_scheduler_state")
 @IdClass(QrtzSchedulerStateEntityPK.class)
 public class QrtzSchedulerStateEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpleTriggersEntity.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_simple_triggers", catalog = "")
+@Table(name = "qrtz_simple_triggers")
 @IdClass(QrtzSimpleTriggersEntityPK.class)
 public class QrtzSimpleTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzSimpropTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_simprop_triggers", catalog = "")
+@Table(name = "qrtz_simprop_triggers")
 @IdClass(QrtzSimpropTriggersEntityPK.class)
 public class QrtzSimpropTriggersEntity {
     private String schedName;

+ 1 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/qrtz/QrtzTriggersEntity.java

@@ -11,7 +11,7 @@ import java.util.Objects;
  * @version 3.0
  */
 @Entity
-@Table(name = "qrtz_triggers", catalog = "")
+@Table(name = "qrtz_triggers")
 @IdClass(QrtzTriggersEntityPK.class)
 public class QrtzTriggersEntity {
     private String schedName;

+ 40 - 46
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/job/BaseJob.java

@@ -21,55 +21,49 @@ import org.springframework.security.core.context.SecurityContextHolder;
 @Slf4j
 public abstract class BaseJob implements Job {
 
-	BaseService baseService;
+    BaseService baseService;
 
-	@Autowired
-	public void setBaseService(BaseService baseService) {
-		this.baseService = baseService;
-	}
+    @Autowired
+    public void setBaseService(BaseService baseService) {
+        this.baseService = baseService;
+    }
 
-	@Override
-	public void execute(JobExecutionContext context) {
+    @Override
+    public void execute(JobExecutionContext context) {
 
-		String method = this.getClass().getName() + ".execute(JobDataMap jobDataMap)";// 执行方法
-		log.info("定时任务:" + method + ",执行开始");
-		String parameter = "";// 参数
-		String errorInfo = "";
-		boolean process;// 执行结果
-		try {
-			// 设置系统用户为job
-			Authentication auth = new UsernamePasswordAuthenticationToken("quartzJob", null);
-			SecurityContextHolder.getContext().setAuthentication(auth);
-			JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
-			parameter = JSONArray.fromObject(jobDataMap).toString();
-			process = this.execute(jobDataMap);
-		} catch (RuntimeException e) {
-			errorInfo = "定时任务执行失败" + e.getMessage();
-			log.error("定时任务执行失败", e);
-			process = false;
-		}
+        String method = this.getClass().getName() + ".execute(JobDataMap jobDataMap)";// 执行方法
+        log.info("定时任务:" + method + ",执行开始");
+        String parameter = "";// 参数
+        boolean process;// 执行结果
+        try {
+            // 设置系统用户为job
+            Authentication auth = new UsernamePasswordAuthenticationToken("quartzJob", null);
+            SecurityContextHolder.getContext().setAuthentication(auth);
+            JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
+            parameter = JSONArray.fromObject(jobDataMap).toString();
+            process = this.execute(jobDataMap);
+        } catch (RuntimeException e) {
+            log.error("定时任务执行失败", e);
+            process = false;
+        }
 
-		if (log.isDebugEnabled()) {
-			log.debug("执行方法:" + method);
-			log.debug("参数:" + parameter);
-			log.debug("执行结果:" + process);
-		}
-		if (!process) {// 如果执行失败,进行告警
-			// 进行告警
-			String name = "定时任务执行失败";
-			String describe = "执行类:" + method + "/r/n参数:" + parameter;
-			String solution = "请检查定时任务";
-			//            this.baseService.saveSysAlarm(AlarmTypeEnum., name, describe,
-			//                SysAlarmPritorityEnum.AlarmPritorityMedium.name(), errorInfo, solution);
-		}
-		log.info("定时任务:" + method + ",执行完成");
-	}
+        if (log.isDebugEnabled()) {
+            log.debug("执行方法:" + method);
+            log.debug("参数:" + parameter);
+            log.debug("执行结果:" + process);
+        }
+        if (!process) {// 如果执行失败,进行告警
+            // 进行告警
+            log.error("定时任务:" + method + ",执行失败");
+        }
+        log.info("定时任务:" + method + ",执行完成");
+    }
 
-	/**
-	 * 任务执行方法
-	 *
-	 * @param jobDataMap 任务参数
-	 * @return 任务执行结果是否成功
-	 */
-	public abstract boolean execute(JobDataMap jobDataMap);
+    /**
+     * 任务执行方法
+     *
+     * @param jobDataMap 任务参数
+     * @return 任务执行结果是否成功
+     */
+    public abstract boolean execute(JobDataMap jobDataMap);
 }

+ 2 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/DataPointRepository.java

@@ -1,5 +1,6 @@
 package com.jiayue.ipfcst.common.data.repository;
 
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.DataPoint;
 
 import java.util.List;
@@ -12,5 +13,5 @@ import java.util.List;
  * @since 2019/8/5 9:15
  */
 public interface DataPointRepository extends BaseRepository<DataPoint, Integer> {
-    List<DataPoint> findAllByEquipmentType(Integer equipmentType);
+    List<DataPoint> findAllByEquipmentType(EquipmentTypeEnum equipmentType);
 }

+ 19 - 18
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/E63UploadFileRuleService.java

@@ -32,10 +32,11 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
      * @param fileType
      * @return
      */
+    @Override
     public List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr) {
         // 计算开始结束时间
         super.caleTime(date);
-        Long startTime = 0L;
+        long startTime;
         String fileName = "";
         List<String> shouldFileNameList = new ArrayList<>();
         Date currentDate = new Date();
@@ -71,21 +72,21 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
             case "E2":
                 int cdqUpMin = 0;
                 try {
-                    Optional<SysParameter> optional = sysParameterRepository.findBySysKeyAndStationCode("CDQ_UP_MIN",electricFieldInfo.getStationCode());
+                    Optional<SysParameter> optional = sysParameterRepository.findBySysKeyAndStationCode("CDQ_UP_MIN", electricFieldInfo.getStationCode());
                     cdqUpMin = Integer.parseInt(optional.map(SysParameter::getSysValue).orElse("0"));
                 } catch (RuntimeException e) {
                     e.printStackTrace();
                 }
                 // 可用超短期
-                midNightTime = midNightTime + cdqUpMin * 1000 * 60;
-                endTime = endTime + cdqUpMin * 1000 * 60;
-                for (Long tempDateTime = midNightTime; tempDateTime < endTime; tempDateTime = tempDateTime + 1 * 60 * 1000) {
-                    if (tempDateTime % (15 * 60 * 1000)==0){
+                midNightTime = midNightTime + (long) cdqUpMin * 1000 * 60;
+                endTime = endTime + (long) cdqUpMin * 1000 * 60;
+                for (long tempDateTime = midNightTime; tempDateTime < endTime; tempDateTime = tempDateTime + 60 * 1000) {
+                    if (tempDateTime % (15 * 60 * 1000) == 0) {
                         // 整15分钟
                         if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                             // 此判断为了当前时刻应上报的文件还没执行定时,产生的多余的应上报
                             if (cronStr != null && !"".equals(cronStr)) {
-                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr,15)) {
+                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
                                     continue;
                                 }
                             }
@@ -105,11 +106,10 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
-                            if (cronStr != null && !"".equals(cronStr)) {
-                                if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
-                                    continue;
-                                }
+                            if (!isEveryTimeShouldFile(tempDateTime, currentDate, cronStr, 15)) {
+                                continue;
                             }
+
                         }
                     }
                     fileName = getFileNameRule(electricFieldInfo, "E27", tempDateTime + 15 * 60 * 1000);
@@ -298,7 +298,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E34":
                 // 超短期日志
-                for (Long tempDateTime = super.midNightTime - 15 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 15 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 15 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -313,7 +313,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E35":
                 // 超短期可用日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -328,7 +328,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E36":
                 // 理论功率日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -343,7 +343,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E37":
                 // 气象站日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -358,7 +358,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E38":
                 // 测风塔日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -373,7 +373,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E39":
                 // 逆变器日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -388,7 +388,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 break;
             case "E40":
                 // 风机日志
-                for (Long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
+                for (long tempDateTime = super.midNightTime - 5 * 60 * 1000; tempDateTime < super.endTime; tempDateTime = tempDateTime + 5 * 60 * 1000) {
                     if (DateFormatUtils.format(super.endTime, "yyyyMMdd").equals(DateFormatUtils.format(currentDate, "yyyyMMdd"))) {
                         // 当天的
                         if (cronStr != null && !"".equals(cronStr)) {
@@ -444,6 +444,7 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
      * @param fileNameTime
      * @return
      */
+    @Override
     public String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime) {
         String fileName = "";
         switch (fileType) {

+ 2 - 2
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/IUploadFileRuleService.java

@@ -16,10 +16,10 @@ public interface IUploadFileRuleService {
     /**
      * 指定日期应该上报文件名称
      */
-    public List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr);
+    List<String> getShouldFile(ElectricField electricFieldInfo, Date date, String fileType, String cronStr);
 
     /**
      * 文件名称生成规则
      */
-    public String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime);
+    String getFileNameRule(ElectricField electricFieldInfo, String fileType, Long fileNameTime);
 }

+ 2 - 2
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/UploadFileRuleCommonService.java

@@ -21,10 +21,10 @@ public class UploadFileRuleCommonService {
     public void caleTime(Date inputParamDate) {
         Date nowDate = new Date();
         // 今日凌晨时间
-        Long nowNightTime = DateMomentUtil.getDayStartTime(nowDate.getTime());
+        long nowNightTime = DateMomentUtil.getDayStartTime(nowDate.getTime());
         // 指定日期的凌晨时间
         midNightTime = DateMomentUtil.getDayStartTime(inputParamDate.getTime());
-        if (nowNightTime.longValue() != midNightTime.longValue()) {
+        if (nowNightTime != midNightTime) {
             endTime = midNightTime + 1000 * 60 * 60 * 24;
         } else {
             endTime = nowDate.getTime();

+ 74 - 167
ipfcst-common/ipfcst-common-data/src/main/java/org/hibernate/cfg/PropertyContainer.java

@@ -30,15 +30,11 @@ import java.util.*;
  * A helper class to keep the {@code XProperty}s of a class ordered by access type.
  *
  * @author Hardy Ferentschik
- *
+ * <p>
  * 修改treeMap 为LinkedHashMap 使字段生成顺序与实体定义顺序一致
  */
 @SuppressWarnings("unused")
 class PropertyContainer {
-//
-//    static {
-//        System.setProperty("jboss.i18n.generate-proxies", "true");
-//    }
 
     private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, org.hibernate.cfg.PropertyContainer.class.getName());
 
@@ -60,7 +56,7 @@ class PropertyContainer {
         this.xClass = clazz;
         this.entityAtStake = entityAtStake;
 
-        if ( defaultClassLevelAccessType == org.hibernate.cfg.AccessType.DEFAULT ) {
+        if (defaultClassLevelAccessType == org.hibernate.cfg.AccessType.DEFAULT) {
             // this is effectively what the old code did when AccessType.DEFAULT was passed in
             // to getProperties(AccessType) from AnnotationBinder and InheritanceState
             defaultClassLevelAccessType = org.hibernate.cfg.AccessType.PROPERTY;
@@ -76,13 +72,13 @@ class PropertyContainer {
 
         this.persistentAttributeMap = new LinkedHashMap<>();
 
-        final List<XProperty> fields = xClass.getDeclaredProperties( org.hibernate.cfg.AccessType.FIELD.getType() );
+        final List<XProperty> fields = xClass.getDeclaredProperties(org.hibernate.cfg.AccessType.FIELD.getType());
 
-        final List<XProperty> getters = xClass.getDeclaredProperties( org.hibernate.cfg.AccessType.PROPERTY.getType() );
+        final List<XProperty> getters = xClass.getDeclaredProperties(org.hibernate.cfg.AccessType.PROPERTY.getType());
 
-        preFilter( fields, getters );
+        preFilter(fields, getters);
 
-        final Map<String,XProperty> persistentAttributesFromGetters = new HashMap<>();
+        final Map<String, XProperty> persistentAttributesFromGetters = new HashMap<>();
 
         collectPersistentAttributesUsingLocalAccessType(
                 persistentAttributeMap,
@@ -100,17 +96,17 @@ class PropertyContainer {
 
     private void preFilter(List<XProperty> fields, List<XProperty> getters) {
         Iterator<XProperty> propertyIterator = fields.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty property = propertyIterator.next();
-            if ( mustBeSkipped( property ) ) {
+            if (mustBeSkipped(property)) {
                 propertyIterator.remove();
             }
         }
 
         propertyIterator = getters.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty property = propertyIterator.next();
-            if ( mustBeSkipped( property ) ) {
+            if (mustBeSkipped(property)) {
                 propertyIterator.remove();
             }
         }
@@ -118,31 +114,31 @@ class PropertyContainer {
 
     private void collectPersistentAttributesUsingLocalAccessType(
             LinkedHashMap<String, XProperty> persistentAttributeMap,
-            Map<String,XProperty> persistentAttributesFromGetters,
+            Map<String, XProperty> persistentAttributesFromGetters,
             List<XProperty> fields,
             List<XProperty> getters) {
 
         // Check fields...
         Iterator<XProperty> propertyIterator = fields.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty xProperty = propertyIterator.next();
-            final Access localAccessAnnotation = xProperty.getAnnotation( Access.class );
-            if ( localAccessAnnotation == null
-                    || localAccessAnnotation.value() != javax.persistence.AccessType.FIELD ) {
+            final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
+            if (localAccessAnnotation == null
+                    || localAccessAnnotation.value() != javax.persistence.AccessType.FIELD) {
                 continue;
             }
 
             propertyIterator.remove();
-            persistentAttributeMap.put( xProperty.getName(), xProperty );
+            persistentAttributeMap.put(xProperty.getName(), xProperty);
         }
 
         // Check getters...
         propertyIterator = getters.iterator();
-        while ( propertyIterator.hasNext() ) {
+        while (propertyIterator.hasNext()) {
             final XProperty xProperty = propertyIterator.next();
-            final Access localAccessAnnotation = xProperty.getAnnotation( Access.class );
-            if ( localAccessAnnotation == null
-                    || localAccessAnnotation.value() != javax.persistence.AccessType.PROPERTY ) {
+            final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
+            if (localAccessAnnotation == null
+                    || localAccessAnnotation.value() != javax.persistence.AccessType.PROPERTY) {
                 continue;
             }
 
@@ -151,60 +147,59 @@ class PropertyContainer {
             final String name = xProperty.getName();
 
             // HHH-10242 detect registration of the same property getter twice - eg boolean isId() + UUID getId()
-            final XProperty previous = persistentAttributesFromGetters.get( name );
-            if ( previous != null ) {
+            final XProperty previous = persistentAttributesFromGetters.get(name);
+            if (previous != null) {
                 throw new org.hibernate.boot.MappingException(
                         LOG.ambiguousPropertyMethods(
                                 xClass.getName(),
-                                HCANNHelper.annotatedElementSignature( previous ),
-                                HCANNHelper.annotatedElementSignature( xProperty )
+                                HCANNHelper.annotatedElementSignature(previous),
+                                HCANNHelper.annotatedElementSignature(xProperty)
                         ),
-                        new Origin( SourceType.ANNOTATION, xClass.getName() )
+                        new Origin(SourceType.ANNOTATION, xClass.getName())
                 );
             }
 
-            persistentAttributeMap.put( name, xProperty );
-            persistentAttributesFromGetters.put( name, xProperty );
+            persistentAttributeMap.put(name, xProperty);
+            persistentAttributesFromGetters.put(name, xProperty);
         }
     }
 
     private void collectPersistentAttributesUsingClassLevelAccessType(
             LinkedHashMap<String, XProperty> persistentAttributeMap,
-            Map<String,XProperty> persistentAttributesFromGetters,
+            Map<String, XProperty> persistentAttributesFromGetters,
             List<XProperty> fields,
             List<XProperty> getters) {
-        if ( classLevelAccessType == org.hibernate.cfg.AccessType.FIELD ) {
-            for ( XProperty field : fields ) {
-                if ( persistentAttributeMap.containsKey( field.getName() ) ) {
+        if (classLevelAccessType == org.hibernate.cfg.AccessType.FIELD) {
+            for (XProperty field : fields) {
+                if (persistentAttributeMap.containsKey(field.getName())) {
                     continue;
                 }
 
-                persistentAttributeMap.put( field.getName(), field );
+                persistentAttributeMap.put(field.getName(), field);
             }
-        }
-        else {
-            for ( XProperty getter : getters ) {
+        } else {
+            for (XProperty getter : getters) {
                 final String name = getter.getName();
 
                 // HHH-10242 detect registration of the same property getter twice - eg boolean isId() + UUID getId()
-                final XProperty previous = persistentAttributesFromGetters.get( name );
-                if ( previous != null ) {
+                final XProperty previous = persistentAttributesFromGetters.get(name);
+                if (previous != null) {
                     throw new org.hibernate.boot.MappingException(
                             LOG.ambiguousPropertyMethods(
                                     xClass.getName(),
-                                    HCANNHelper.annotatedElementSignature( previous ),
-                                    HCANNHelper.annotatedElementSignature( getter )
+                                    HCANNHelper.annotatedElementSignature(previous),
+                                    HCANNHelper.annotatedElementSignature(getter)
                             ),
-                            new Origin( SourceType.ANNOTATION, xClass.getName() )
+                            new Origin(SourceType.ANNOTATION, xClass.getName())
                     );
                 }
 
-                if ( persistentAttributeMap.containsKey( name ) ) {
+                if (persistentAttributeMap.containsKey(name)) {
                     continue;
                 }
 
-                persistentAttributeMap.put( getter.getName(), getter );
-                persistentAttributesFromGetters.put( name, getter );
+                persistentAttributeMap.put(getter.getName(), getter);
+                persistentAttributesFromGetters.put(name, getter);
             }
         }
     }
@@ -223,96 +218,19 @@ class PropertyContainer {
 
     public Collection<XProperty> getProperties() {
         assertTypesAreResolvable();
-        return Collections.unmodifiableCollection( persistentAttributeMap.values() );
+        return Collections.unmodifiableCollection(persistentAttributeMap.values());
     }
 
     private void assertTypesAreResolvable() {
-        for ( XProperty xProperty : persistentAttributeMap.values() ) {
-            if ( !xProperty.isTypeResolved() && !discoverTypeWithoutReflection( xProperty ) ) {
-                String msg = "Property " + StringHelper.qualify( xClass.getName(), xProperty.getName() ) +
+        for (XProperty xProperty : persistentAttributeMap.values()) {
+            if (!xProperty.isTypeResolved() && !discoverTypeWithoutReflection(xProperty)) {
+                String msg = "Property " + StringHelper.qualify(xClass.getName(), xProperty.getName()) +
                         " has an unbound type and no explicit target entity. Resolve this Generic usage issue" +
                         " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type";
-                throw new AnnotationException( msg );
+                throw new AnnotationException(msg);
             }
         }
     }
-//
-//	private void considerExplicitFieldAndPropertyAccess() {
-//		for ( XProperty property : fieldAccessMap.values() ) {
-//			Access access = property.getAnnotation( Access.class );
-//			if ( access == null ) {
-//				continue;
-//			}
-//
-//			// see "2.3.2 Explicit Access Type" of JPA 2 spec
-//			// the access type for this property is explicitly set to AccessType.FIELD, hence we have to
-//			// use field access for this property even if the default access type for the class is AccessType.PROPERTY
-//			AccessType accessType = AccessType.getAccessStrategy( access.value() );
-//            if (accessType == AccessType.FIELD) {
-//				propertyAccessMap.put(property.getName(), property);
-//			}
-//            else {
-//				LOG.debug( "Placing @Access(AccessType.FIELD) on a field does not have any effect." );
-//			}
-//		}
-//
-//		for ( XProperty property : propertyAccessMap.values() ) {
-//			Access access = property.getAnnotation( Access.class );
-//			if ( access == null ) {
-//				continue;
-//			}
-//
-//			AccessType accessType = AccessType.getAccessStrategy( access.value() );
-//
-//			// see "2.3.2 Explicit Access Type" of JPA 2 spec
-//			// the access type for this property is explicitly set to AccessType.PROPERTY, hence we have to
-//			// return use method access even if the default class access type is AccessType.FIELD
-//            if (accessType == AccessType.PROPERTY) {
-//				fieldAccessMap.put(property.getName(), property);
-//			}
-//            else {
-//				LOG.debug( "Placing @Access(AccessType.PROPERTY) on a field does not have any effect." );
-//			}
-//		}
-//	}
-
-//	/**
-//	 * Retrieves all properties from the {@code xClass} with the specified access type. This method does not take
-//	 * any jpa access rules/annotations into account yet.
-//	 *
-//	 * @param access The access type - {@code AccessType.FIELD}  or {@code AccessType.Property}
-//	 *
-//	 * @return A maps of the properties with the given access type keyed against their property name
-//	 */
-//	private TreeMap<String, XProperty> initProperties(AccessType access) {
-//		if ( !( AccessType.PROPERTY.equals( access ) || AccessType.FIELD.equals( access ) ) ) {
-//			throw new IllegalArgumentException( "Access type has to be AccessType.FIELD or AccessType.Property" );
-//		}
-//
-//		//order so that property are used in the same order when binding native query
-//		TreeMap<String, XProperty> propertiesMap = new TreeMap<String, XProperty>();
-//		List<XProperty> properties = xClass.getDeclaredProperties( access.getType() );
-//		for ( XProperty property : properties ) {
-//			if ( mustBeSkipped( property ) ) {
-//				continue;
-//			}
-//			// HHH-10242 detect registration of the same property twice eg boolean isId() + UUID getId()
-//			XProperty oldProperty = propertiesMap.get( property.getName() );
-//			if ( oldProperty != null ) {
-//				throw new org.hibernate.boot.MappingException(
-//						LOG.ambiguousPropertyMethods(
-//								xClass.getName(),
-//								HCANNHelper.annotatedElementSignature( oldProperty ),
-//								HCANNHelper.annotatedElementSignature( property )
-//						),
-//						new Origin( SourceType.ANNOTATION, xClass.getName() )
-//				);
-//			}
-//
-//			propertiesMap.put( property.getName(), property );
-//		}
-//		return propertiesMap;
-//	}
 
     @SuppressWarnings("deprecation")
     private org.hibernate.cfg.AccessType determineLocalClassDefinedAccessStrategy() {
@@ -321,75 +239,64 @@ class PropertyContainer {
         org.hibernate.cfg.AccessType hibernateDefinedAccessType = org.hibernate.cfg.AccessType.DEFAULT;
         org.hibernate.cfg.AccessType jpaDefinedAccessType = org.hibernate.cfg.AccessType.DEFAULT;
 
-        org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class );
-        if ( accessType != null ) {
-            hibernateDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy( accessType.value() );
+        org.hibernate.annotations.AccessType accessType = xClass.getAnnotation(org.hibernate.annotations.AccessType.class);
+        if (accessType != null) {
+            hibernateDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy(accessType.value());
         }
 
-        Access access = xClass.getAnnotation( Access.class );
-        if ( access != null ) {
-            jpaDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy( access.value() );
+        Access access = xClass.getAnnotation(Access.class);
+        if (access != null) {
+            jpaDefinedAccessType = org.hibernate.cfg.AccessType.getAccessStrategy(access.value());
         }
 
-        if ( hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
+        if (hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
                 && jpaDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT
-                && hibernateDefinedAccessType != jpaDefinedAccessType ) {
+                && hibernateDefinedAccessType != jpaDefinedAccessType) {
             throw new MappingException(
                     "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. "
             );
         }
 
-        if ( hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT ) {
+        if (hibernateDefinedAccessType != org.hibernate.cfg.AccessType.DEFAULT) {
             classDefinedAccessType = hibernateDefinedAccessType;
-        }
-        else {
+        } else {
             classDefinedAccessType = jpaDefinedAccessType;
         }
         return classDefinedAccessType;
     }
 
     private static boolean discoverTypeWithoutReflection(XProperty p) {
-        if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
+        if (p.isAnnotationPresent(OneToOne.class) && !p.getAnnotation(OneToOne.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( OneToMany.class ) && !p.getAnnotation( OneToMany.class )
+        } else if (p.isAnnotationPresent(OneToMany.class) && !p.getAnnotation(OneToMany.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
+        } else if (p.isAnnotationPresent(ManyToOne.class) && !p.getAnnotation(ManyToOne.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
+        } else if (p.isAnnotationPresent(ManyToMany.class) && !p.getAnnotation(ManyToMany.class)
                 .targetEntity()
-                .equals( void.class ) ) {
+                .equals(void.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
+        } else if (p.isAnnotationPresent(org.hibernate.annotations.Any.class)) {
             return true;
-        }
-        else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
-            if ( !p.isCollection() && !p.isArray() ) {
-                throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
+        } else if (p.isAnnotationPresent(ManyToAny.class)) {
+            if (!p.isCollection() && !p.isArray()) {
+                throw new AnnotationException("@ManyToAny used on a non collection non array property: " + p.getName());
             }
             return true;
-        }
-        else if ( p.isAnnotationPresent( Type.class ) ) {
-            return true;
-        }
-        else if ( p.isAnnotationPresent( Target.class ) ) {
+        } else if (p.isAnnotationPresent(Type.class)) {
             return true;
-        }
-        return false;
+        } else return p.isAnnotationPresent(Target.class);
     }
 
     private static boolean mustBeSkipped(XProperty property) {
-        return property.isAnnotationPresent( Transient.class )
-                || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() )
-                || "org.hibernate.bytecode.internal.javassist.FieldHandler".equals( property.getType().getName() );
+        return property.isAnnotationPresent(Transient.class)
+                || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals(property.getType().getName())
+                || "org.hibernate.bytecode.internal.javassist.FieldHandler".equals(property.getType().getName());
     }
 }

+ 1 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SecurityAuthorizeConfigurerProvider.java

@@ -7,19 +7,14 @@ import org.springframework.stereotype.Component;
 
 /**
  * Security身份认证相关的授权配置
- *
  */
 @Component
-@Order(Integer.MAX_VALUE) // 值越小加载越优先,值越大加载越靠后
+@Order() // 值越小加载越优先,值越大加载越靠后
 public class SecurityAuthorizeConfigurerProvider implements AuthorizeConfigurerProvider {
 
 
-
-
     @Override
     public void confiure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-       /* config.antMatchers(""
-        ).permitAll(); // 放行登录页面访问*/
 
         // 其他请求都要通过身份认证
         config.anyRequest().authenticated();

+ 7 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SysAuthorizeConfigurerManager.java

@@ -1,6 +1,5 @@
 package com.jiayue.ipfcst.common.security.authorize;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
 import org.springframework.stereotype.Component;
@@ -9,18 +8,20 @@ import java.util.List;
 
 /**
  * 管理security配置
- *
- *
  */
 @Component
-public class SysAuthorizeConfigurerManager  {
+public class SysAuthorizeConfigurerManager {
 
-    @Autowired
+    final
     List<AuthorizeConfigurerProvider> authorizeConfigurerProviders;
 
+    public SysAuthorizeConfigurerManager(List<AuthorizeConfigurerProvider> authorizeConfigurerProviders) {
+        this.authorizeConfigurerProviders = authorizeConfigurerProviders;
+    }
+
     // 将一个个AuthorizeConfigurerProvider的实现类,传入配置的参数 ExpressionInterceptUrlRegistry
     public void configure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-        for(AuthorizeConfigurerProvider provider: authorizeConfigurerProviders) {
+        for (AuthorizeConfigurerProvider provider : authorizeConfigurerProviders) {
             provider.confiure(config);
         }
     }

+ 0 - 8
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/authorize/SystemAuthorizeConfigurerProvider.java

@@ -6,19 +6,11 @@ import org.springframework.stereotype.Component;
 
 /**
  * Security授权配置
- *
  */
 @Component
 public class SystemAuthorizeConfigurerProvider implements AuthorizeConfigurerProvider {
 
     @Override
     public void confiure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
-//        // 有 sys:user 权限的可以访问任意请求方式的/role
-//        config.antMatchers("/user").hasAuthority("sys:user")
-//        // 有 sys:role 权限的可以访问 get方式的/role
-//        .antMatchers(HttpMethod.GET,"/role").hasAuthority("sys:role")
-//        .antMatchers(HttpMethod.GET, "/permission")
-//        // ADMIN 注意角色会在前面加上前缀 ROLE_ , 也就是完整的是 ROLE_ADMIN, ROLE_ROOT
-//        .access("hasAuthority('sys:permission') or hasAnyRole('ADMIN', 'ROOT')");
     }
 }

+ 4 - 4
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/filter/JwtAuthenticationTokenFilter.java

@@ -33,14 +33,14 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
 
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws
-        ServletException, IOException {
-         SecurityContextHolder.getContext().getAuthentication();
+            ServletException, IOException {
+        SecurityContextHolder.getContext().getAuthentication();
         String token = request.getHeader("Authorization");
         if (!StringUtils.isEmpty(token)) {
             String username = jwtTokenUtil.getUsernameFromToken(token);
-            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null){
+            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
                 UserDetails userDetails = jwtUserDetailsServiceImpl.loadUserByUsername(username);
-                if (jwtTokenUtil.validateToken(token, userDetails)){
+                if (jwtTokenUtil.validateToken(token, userDetails)) {
                     // 将用户信息存入 authentication,方便后续校验
                     UsernamePasswordAuthenticationToken
                             authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());

+ 9 - 13
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationFailureHandler.java

@@ -4,12 +4,10 @@ import cn.hutool.json.JSONUtil;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.security.user.SysUser;
 import com.jiayue.ipfcst.common.security.user.SysUserService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
 import org.springframework.stereotype.Component;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -20,26 +18,25 @@ import java.io.IOException;
 @Component("customAuthenticationFailureHandler")
 public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
 
-    @Autowired
+    final
     SysUserService sysUserService;
 
+    public CustomAuthenticationFailureHandler(SysUserService sysUserService) {
+        this.sysUserService = sysUserService;
+    }
+
     @Override
     public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
-                                        AuthenticationException e) throws IOException, ServletException {
+                                        AuthenticationException e) throws IOException {
         String username = httpServletRequest.getParameter("username");
-        String errorTips = "";
+        String errorTips;
         SysUser user = sysUserService.findByUserName(username);
-        if (username.equals("admin") || username.equals("consumer")) {
-            errorTips = "用户名或密码不正常";
-        } else {
-            errorTips = "用户名或密码不正常";
-        }
 
         if (user == null) {
             errorTips = "用户名或密码不正常";
         } else {
             if (user.getStatus().equals("1")) {
-                Long xz = (user.getLockTime() + 300000 - System.currentTimeMillis()) / 1000;
+                long xz = (user.getLockTime() + 300000 - System.currentTimeMillis()) / 1000;
                 if (xz < 0) {
                     user.setStatus("0");
                     user.setPwdErrNum(1);
@@ -56,14 +53,13 @@ public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationF
                     errorTips = "用户名或密码不正常,还有" + (errCount - errNum) + "次机会";
                     errNum++;
                     user.setPwdErrNum(errNum);
-                    sysUserService.save(user);
                 } else {
                     errorTips = "用户锁定,稍后再试";
                     user.setPwdErrNum(0);
                     user.setStatus("1");
                     user.setLockTime(System.currentTimeMillis());
-                    sysUserService.save(user);
                 }
+                sysUserService.save(user);
 
             }
 

+ 8 - 6
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/handle/CustomAuthenticationSuccessHandler.java

@@ -5,14 +5,12 @@ import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.security.user.SysUser;
 import com.jiayue.ipfcst.common.security.user.SysUserService;
 import com.jiayue.ipfcst.common.security.util.JwtTokenUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
 import org.springframework.stereotype.Component;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -23,14 +21,18 @@ import java.io.IOException;
 @Component("customAuthenticationSuccessHandler")
 public class CustomAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
 
-    @Autowired
-    private JwtTokenUtil jwtTokenUtil;
+    private final JwtTokenUtil jwtTokenUtil;
 
-    @Autowired
+    final
     SysUserService sysUserService;
 
+    public CustomAuthenticationSuccessHandler(JwtTokenUtil jwtTokenUtil, SysUserService sysUserService) {
+        this.jwtTokenUtil = jwtTokenUtil;
+        this.sysUserService = sysUserService;
+    }
+
     @Override
-    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
+    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException {
         User user = (User) authentication.getPrincipal();
         SecurityContextHolder.getContext().setAuthentication(authentication);
         String token = jwtTokenUtil.generateToken(user);

+ 4 - 18
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/JwtUserDetailsServiceImpl.java

@@ -26,24 +26,12 @@ public class JwtUserDetailsServiceImpl implements UserDetailsService {
 
     @Override
     public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
-        User user = null;
-        String password = null;
+        User user;
+        String password;
         SysUser sysUser = sysUserService.findByUserName(username);
-//        if ("admin".equals(username)) {
-//            if (sysUser == null || sysUser.getUserName().isEmpty()) {
-//                sysUser = new SysUser();
-//                sysUser.setUserName("admin");
-//                sysUser.setPassWord("!QAZ2wsx");
-//                sysUser.setName("admin");
-//                sysUser.setPwdErrNum(0);
-//                sysUser.setLockTime(0L);
-//                sysUser.setStatus("0");
-//                sysUserService.save(sysUser);
-//            }
-//        }
-        if(sysUser == null){
+        if (sysUser == null) {
             password = passwordEncoder.encode("sda21dsad13214sda22dsa@#$#$%!ds1d1");
-        }else {
+        } else {
             password = passwordEncoder.encode(sysUser.getPassWord());
             if (sysUser.getStatus().equals("1") && (System.currentTimeMillis() - sysUser.getLockTime()) < 300000) {
                 password = passwordEncoder.encode("sda21dsad13214sda22dsa@#$#$%!ds1d1");
@@ -55,8 +43,6 @@ public class JwtUserDetailsServiceImpl implements UserDetailsService {
         }
 
 
-
-
         user = new User(username, password, AuthorityUtils.commaSeparatedStringToAuthorityList(username.toUpperCase()));
         return user;
     }

+ 6 - 3
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/user/SysUserService.java

@@ -1,7 +1,6 @@
 package com.jiayue.ipfcst.common.security.user;
 
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -17,9 +16,13 @@ import java.util.List;
 @Slf4j
 public class SysUserService {
 
-    @Autowired
+    final
     SysUserRepository sysUserRepository;
 
+    public SysUserService(SysUserRepository sysUserRepository) {
+        this.sysUserRepository = sysUserRepository;
+    }
+
     public SysUser findByUserName(String username) {
         return sysUserRepository.findByUserName(username);
     }
@@ -36,7 +39,7 @@ public class SysUserService {
     public void delete(String ids) {
         if (!StringUtils.isEmpty(ids)) {
             String[] idArray = ids.split(",");
-            if (idArray != null && idArray.length > 0) {
+            if (idArray.length > 0) {
                 for (String id : idArray) {
                     this.sysUserRepository.deleteById(Integer.valueOf(id));
                     log.info("删除用户ID为[" + id + "]成功!");

+ 1 - 20
ipfcst-common/ipfcst-common-security/src/main/java/com/jiayue/ipfcst/common/security/util/JwtTokenUtil.java

@@ -15,7 +15,6 @@ import java.util.Map;
 
 /**
  * 生成令牌,验证等等一些操作
- *
  */
 @Data
 @Component
@@ -63,7 +62,7 @@ public class JwtTokenUtil {
      * @return 令牌
      */
     public String generateToken(UserDetails userDetails) {
-        Map<String, Object> claims = new HashMap<String, Object>();
+        Map<String, Object> claims = new HashMap<>();
         claims.put(Claims.SUBJECT, userDetails.getUsername());
         claims.put(Claims.ISSUED_AT, new Date());
         return generateToken(claims);
@@ -103,24 +102,6 @@ public class JwtTokenUtil {
     }
 
     /**
-     * 刷新令牌
-     *
-     * @param token 原令牌
-     * @return 新令牌
-     */
-    public String refreshToken(String token) {
-        String refreshedToken;
-        try {
-            Claims claims = getClaimsFromToken(token);
-            claims.put(Claims.ISSUED_AT, new Date());
-            refreshedToken = generateToken(claims);
-        } catch (Exception e) {
-            refreshedToken = null;
-        }
-        return refreshedToken;
-    }
-
-    /**
      * 验证令牌
      *
      * @param token       令牌

+ 5 - 1
ipfcst-console/pom.xml

@@ -115,7 +115,11 @@
       <artifactId>fastjson</artifactId>
       <version>${fastjson.version}</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.8</version>
+    </dependency>
     <dependency>
       <groupId>org.reflections</groupId>
       <artifactId>reflections</artifactId>

+ 409 - 459
ipfcst-console/src/main/frontend/views/console/inverterInfo/index.vue

@@ -12,7 +12,7 @@
           </el-button>
         </div>
         <span style="font-weight: bold;font-size: 14px">场站名称:</span>
-        <el-select style="width:250px" clearable v-model="stationCode" size="small" >
+        <el-select v-model="stationCode" clearable size="small" style="width:250px">
           <el-option
             v-for="item in stationList"
             :key="item.stationCode"
@@ -22,123 +22,95 @@
             <span style="float: right; color: #8492a6;font-size: 13px">{{ item.stationCode }}</span>
           </el-option>
         </el-select>
-        <el-button type="primary" icon="el-icon-search" size="small" @click="getData">查询</el-button>
-        <el-button type="primary" @click="insertEvent" size="small" style="round-clip: 10px" :loading="loadButton">添加</el-button>
+        <el-button icon="el-icon-search" size="small" type="primary" @click="getData">查询</el-button>
+        <el-button :loading="loadButton" size="small" style="round-clip: 10px" type="primary" @click="insertEvent">添加
+        </el-button>
         <el-button
-          size="small"
           :loading="loadButton"
-          type="primary"
+          size="small"
           style="round-clip: 10px"
+          type="primary"
           @click="piInsertEvent">
           批量添加
         </el-button>
         <el-button
-          size="small"
           :loading="loadButton"
-          type="danger"
+          size="small"
           style="round-clip: 10px"
+          type="danger"
           @click="getSelectionEvent">
           批量删除
         </el-button>
         <div style="padding-top: 10px">
           <vxe-table
+            v-show="showTable"
             ref="xTable"
+            :data="tableData"
+            :edit-config="{trigger: 'manual', mode: 'row',autoClear:false,showStatus: true,icon:'none'}"
+            :edit-rules="rules"
+            :loading="loading"
+            auto-resize
             border
             export-config
-            keep-source
-            auto-resize
-            resizable
             highlight-current-row
-            :loading="loading"
-            :edit-rules="rules"
-            :data="tableData"
-            v-show="showTable"
-            :edit-config="{trigger: 'manual', mode: 'row',autoClear:false,showStatus: true,icon:'none'}">
-            <vxe-table-column title="逆变器信息" align="center">
+            keep-source
+            resizable>
+            <vxe-table-column align="center" title="逆变器信息">
               <vxe-table-column type="checkbox" width="3%"></vxe-table-column>
-              <vxe-table-column field="stationCode" title="场站编号" width="6%"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="equipmentNo" width="10%" title="设备编号"
-                                :edit-render="{name:'$input',attrs:{type:'text'}}"></vxe-table-column>
-              <vxe-table-column field="name" title="名称" width="8%" align="center"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="modelNumber" title="型号" width="8%" align="center"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="manufacturer" title="生产商" width="8%" align="center"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column width="150px" field="installationTime" title="安装时间" align="center"
-                                :edit-render="{props: {type: 'default'}}">
-                <template v-slot:edit="{ row }">
-                  <el-date-picker
-                    size="mini"
-                    v-model="row.installationTime"
-                    style="width: 100%"
-                    type="date"
-                    placeholder="选择日期:"
-                  />
-                </template>
-                <template v-slot="{ row }">{{ timestampToTime(row.installationTime) }}</template>
-              </vxe-table-column>
-              <vxe-table-column field="report" title="是否上报" width="8%" align="center"
-                                :edit-render="{name: '$select', options: trueOrFalse}"></vxe-table-column>
-              <vxe-table-column field="capacity" title="额定功率" width="8%" align="center"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="efficiency" title="效率" width="8%" align="center"
-                                :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="box" title="箱式变压器" width="8%" align="center"
-                                :edit-render="{name: '$input', props: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="collectorCircuit" title="集电线路" width="8%" align="center"
-                                :edit-render="{name: '$input', props: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="batteryModel" title="光组型号" width="8%" align="center"
-                                :edit-render="{name: '$select', options: pvInfoMode}"></vxe-table-column>
-              <vxe-table-column field="batteryNumber" title="光组个数" width="8%" align="center"
-                                :edit-render="{name: '$input', props: {type: 'number'}}"></vxe-table-column>
-              <vxe-table-column field="groupSeries" title="是否组串" width="6%" align="center"
-                                :edit-render="{name: '$select', options: trueOrFalse}"></vxe-table-column>
-              <vxe-table-column field="sample" title="是否样板" width="6%" align="center"
-                                :edit-render="{name: '$select', options: trueOrFalse}"></vxe-table-column>
-              <vxe-table-column field="backupA" width="10%" title="样板机编号"
-                :edit-render="{name: '$input',attrs:{type:'text'}}"/>
-              <vxe-table-column field="backupB" title="经度" width="8%" align="center"
-                                :edit-render="{name: '$input', props: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="backupC" title="纬度" width="8%" align="center"
-                                :edit-render="{name: '$input', props: {type: 'text'}}"></vxe-table-column>
-              <vxe-table-column field="interval" title="入库间隔(单位s)" width="8%" align="center"
-                                :edit-render="{name: '$select', options: intervals}"></vxe-table-column>
-              <vxe-table-column title="操作" fixed="right" width="10%" align="center">
+              <vxe-table-column :edit-render="{name: '$input', attrs: {type: 'text'}}" field="stationCode" title="场站编号"
+                                width="6%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name:'$input',attrs:{type:'text'}}" field="equipmentNo" title="设备编号"
+                                width="10%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$input', attrs: {type: 'text'}}" align="center" field="name" title="名称"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$input', attrs: {type: 'text'}}" align="center" field="modelNumber" title="型号"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$select', options: trueOrFalse}" align="center" field="report" title="是否上报"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$input', attrs: {type: 'text'}}" align="center" field="capacity" title="额定功率"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$input', attrs: {type: 'text'}}" align="center" field="efficiency" title="效率"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$input', props: {type: 'text'}}" align="center" field="collectorCircuit" title="集电线路"
+                                width="8%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$select', options: trueOrFalse}" align="center" field="groupSeries" title="是否组串"
+                                width="6%"></vxe-table-column>
+              <vxe-table-column :edit-render="{name: '$select', options: trueOrFalse}" align="center" field="sample" title="是否样板"
+                                width="6%"></vxe-table-column>
+              <vxe-table-column align="center" fixed="right" title="操作" width="10%">
                 <template v-slot="{ row }">
                   <template v-if="$refs.xTable.isActiveByRow(row)">
                     <el-button
-                      type="success"
-                      style="padding: 3px 4px 3px 4px;margin: 2px;"
-                      size="medium"
                       icon="el-icon-edit"
+                      size="medium"
+                      style="padding: 3px 4px 3px 4px;margin: 2px;"
+                      type="success"
                       @click="editSave(row)">保存
                     </el-button>
                     <el-button
                       class="cancel-btn"
                       icon="el-icon-refresh"
-                      type="warning"
-                      style="padding: 3px 4px 3px 4px;margin: 2px;"
                       size="medium"
+                      style="padding: 3px 4px 3px 4px;margin: 2px;"
+                      type="warning"
                       @click="cancelRowEvent(row)">取消
                     </el-button>
                   </template>
                   <template v-else>
                     <el-button
                       :loading="loadButton"
-                      type="primary"
-                      style="padding: 3px 4px 3px 4px;margin: 2px;"
-                      size="medium "
                       icon="el-icon-edit"
+                      size="medium "
+                      style="padding: 3px 4px 3px 4px;margin: 2px;"
+                      type="primary"
                       @click="editRowEvent(row)">编辑
                     </el-button>
                     <el-button
                       :loading="loadButton"
-                      type="danger"
-                      style="padding: 3px 4px 3px 4px;margin: 2px;"
-                      size="medium "
                       icon="el-icon-delete"
+                      size="medium "
+                      style="padding: 3px 4px 3px 4px;margin: 2px;"
+                      type="danger"
                       @click="deleteRowEvent(row)">删除
                     </el-button>
                   </template>
@@ -148,21 +120,21 @@
             </vxe-table-column>
           </vxe-table>
           <vxe-pager
-            perfect
+            v-show="!loadButton&&showTable"
             :current-page.sync="currentPage"
+            :layouts="['PrevJump', 'PrevPage','JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
             :page-size.sync="pageSize"
-            :total="total"
             :page-sizes=[10,50,100]
-            :layouts="['PrevJump', 'PrevPage','JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
+            :total="total"
+            perfect
             @page-change="handlePageChange"
-            v-show="!loadButton&&showTable"
           >
           </vxe-pager>
         </div>
       </el-card>
     </div>
     <!-- 删除提示框 -->
-    <el-dialog :visible.sync="delVisible" title="提示" width="300px" center>
+    <el-dialog :visible.sync="delVisible" center title="提示" width="300px">
       <div class="del-dialog-cnt">删除不可恢复,是否确定删除?</div>
       <span slot="footer" class="dialog-footer">
                 <el-button type="primary" @click="deleteCancel()">取 消</el-button>
@@ -173,420 +145,398 @@
 </template>
 
 <script>
-  import request from '@/utils/request'
 
-  export default {
-    data() {
-      const checkName = (rule, value, callback) => {
-        var s6 = this.tableData
-        if (value == null || value === '') {
-          callback(new Error('请填写逆变器名称'))
-        }
-        for (let i = 0; i < s6.length; i++) {
-          if (this.id == '' || this.id == undefined) {
-            // 新增
+export default {
+  data() {
+    const checkName = (rule, value, callback) => {
+      var s6 = this.tableData
+      if (value == null || value === '') {
+        callback(new Error('请填写逆变器名称'))
+      }
+      for (let i = 0; i < s6.length; i++) {
+        if (this.id == '' || this.id == undefined) {
+          // 新增
+          if ((value == s6[i].name)) {
+            callback(new Error('名称不能重复'))
+          }
+        } else {
+          // 修改
+          if (this.id != s6[i].id) {
             if ((value == s6[i].name)) {
               callback(new Error('名称不能重复'))
             }
-          } else {
-            // 修改
-            if (this.id != s6[i].id) {
-              if ((value == s6[i].name)) {
-                callback(new Error('名称不能重复'))
-              }
-            }
           }
         }
-        callback()
       }
-      return {
-        stationCode: '',
-        stationList: [],
-        id:'',
-        currentPage: 1,
-        pageSize: 10,
-        total: 0,
-        isSample: '',
-        piadd: '',
-        loadButton: false,
-        loading: false,
-        rowId: "",
-        options: [{value: true, label: '样板机'},
-          {value: null, label: '所有'}],
-        option: "",
-        tableData: [],
-        showTable: true,
-        batchAddData: [],
-        delVisible: false,
-        //是否为编辑
-        isEdit: false,
-        pvInfo: [],
-        pvInfoMode: [],
-        pvRotationMode: [],
-        trueOrFalse: [{label: '是', value: true},
-          {label: '否', value: false}],
-        intervals:[{ key: 0, value: 0, label: '不入库' },{key:60,value:60,label:'一分钟'},{key:900,value:900,label:'十五分钟'}],
-        // 表单验证规则
-        rules: {
-          name: [
-            {required: true,  validator:checkName}
-          ],
-          modelNumber: [
-            {required: true, message: '逆变器型号不能为空', trigger: 'blur'}
-          ],
-          capacity: [
-            {required: true, message: '额定容量不能为空', trigger: 'blur'},
-            {pattern: /^\d+(\.\d{1,2})?$/, message: '只能输入正数数字或带小数点2位以内的数字'},
-          ],
-          efficiency: [
-            {required: true, message: '逆变器效率不能为空', trigger: 'blur'},
-            {pattern: /^\d+(\.\d{1,2})?$/, message: '只能输入正数数字或带小数点2位以内的数字'},
-          ],
-          backupB: [
-            { required: true, message: '请正确填写经度' },
-            {pattern: /^\d+(\.\d{1,4})?$/, message: '只能输入正数数字或带小数点4位以内的数字'}
-            // {message: '输入过长', max: 10}
-          ],
-          backupC: [
-            { required: true, message: '请正确填写纬度' },
-            {pattern: /^\d+(\.\d{1,4})?$/, message: '只能输入正数数字或带小数点4位以内的数字'}
-            // {message: '输入过长', max: 10}
-          ],
-          box: [
-            {required: true, message: '箱变不能为空', trigger: 'blur'},
-          ],
-          collectorCircuit: [
-            {required: true, message: '集电线不能为空', trigger: 'blur'},
-          ],
-          batteryModel: [
-            {required: true, message: '光组型号不能为空', trigger: 'blur'},
-          ],
-          batteryNumber: [
-            {required: true, message: '光组个数不能为空', trigger: 'blur'}
-          ],
-          groupSeries: [
-            {required: true, message: '是否组串式逆变器不能为空', trigger: 'change'}
-          ],
-          sample: [
-            {required: true, message: '是否样板机不能为空', trigger: 'change'}
-          ],
-          manufacturer: [
-            {required: true, message: '制造商名称不能为空'},
-          ],
-          installationTime: [
-            {required: true, message: '请选择日期'}
-          ],
-          report: [
-            {required: true, message: '是否上报不能为空', trigger: 'change'}
-          ]
-        }
+      callback()
+    }
+    return {
+      stationCode: '',
+      stationList: [],
+      id: '',
+      currentPage: 1,
+      pageSize: 10,
+      total: 0,
+      isSample: '',
+      piadd: '',
+      loadButton: false,
+      loading: false,
+      rowId: "",
+      options: [{value: true, label: '样板机'},
+        {value: null, label: '所有'}],
+      option: "",
+      tableData: [],
+      showTable: true,
+      batchAddData: [],
+      delVisible: false,
+      //是否为编辑
+      isEdit: false,
+      pvInfo: [],
+      pvInfoMode: [],
+      pvRotationMode: [],
+      trueOrFalse: [{label: '是', value: true},
+        {label: '否', value: false}],
+      intervals: [{key: 0, value: 0, label: '不入库'}, {key: 60, value: 60, label: '一分钟'}, {
+        key: 900,
+        value: 900,
+        label: '十五分钟'
+      }],
+      // 表单验证规则
+      rules: {
+        name: [
+          {required: true, validator: checkName}
+        ],
+        modelNumber: [
+          {required: true, message: '逆变器型号不能为空', trigger: 'blur'}
+        ],
+        capacity: [
+          {required: true, message: '额定容量不能为空', trigger: 'blur'},
+          {pattern: /^\d+(\.\d{1,2})?$/, message: '只能输入正数数字或带小数点2位以内的数字'},
+        ],
+        efficiency: [
+          {required: true, message: '逆变器效率不能为空', trigger: 'blur'},
+          {pattern: /^\d+(\.\d{1,2})?$/, message: '只能输入正数数字或带小数点2位以内的数字'},
+        ],
+        collectorCircuit: [
+          {required: true, message: '集电线不能为空', trigger: 'blur'},
+        ],
+        groupSeries: [
+          {required: true, message: '是否组串式逆变器不能为空', trigger: 'change'}
+        ],
+        sample: [
+          {required: true, message: '是否样板机不能为空', trigger: 'change'}
+        ],
+        report: [
+          {required: true, message: '是否上报不能为空', trigger: 'change'}
+        ]
       }
-    },
+    }
+  },
 
-    created() {
-      this.getStationList()
-      this.getData()
+  created() {
+    this.getStationList()
+    this.getData()
+  },
+  activated() {
+    console.log("2激活activated钩子函数");
+  },
+  deactivated() {
+    console.log("2激活deactivated钩子函数");
+  },
+  methods: {
+    getStationList() {
+      this.$axios.get('/electricField/getElectricField').then((res) => {
+        this.stationList = res.data
+      }).catch((error) => {
+        this.$message.error('获取场站下拉框出错' + error)
+      })
     },
-    activated() {
-      console.log("2激活activated钩子函数");
+    getData() {
+      this.loading = true
+      let queryParam = this.stationCode;
+      if (queryParam == '') {
+        queryParam = "ALL"
+      }
+      let url = this.currentPage + '/' + this.pageSize + '/' + queryParam
+      this.$axios.get('/inverterInfo/' + url).then(res => {
+        this.tableData = res.data.content
+        this.total = res.data.totalElements
+        this.loading = false
+        // console.log(res.data)
+        this.getPvData()
+      }).catch((error) => {
+        this.$message.error('获取逆变器信息出错' + error)
+      })
     },
-    deactivated() {
-      console.log("2激活deactivated钩子函数");
+    handlePageChange({currentPage, pageSize}) {
+      this.currentPage = currentPage
+      this.pageSize = pageSize
+      this.getData()
     },
-    methods: {
-      getStationList() {
-        this.$axios.get('/electricField/getElectricField').then((res) => {
-          this.stationList = res.data
-        }).catch((error) => {
-          this.$message.error('获取场站下拉框出错' + error)
-        })
-      },
-      getData() {
-        this.loading = true
-        let queryParam = this.stationCode;
-        if (queryParam==''){
-          queryParam="ALL"
-        }
-        let url = this.currentPage + '/' + this.pageSize + '/' + queryParam
-        this.$axios.get('/inverterInfo/' + url).then(res => {
-          this.tableData = res.data.content
-          this.total = res.data.totalElements
-          this.loading = false
-          // console.log(res.data)
-          this.getPvData()
-        }).catch((error) => {
-          this.$message.error('获取逆变器信息出错' + error)
-        })
-      },
-      handlePageChange({currentPage, pageSize}) {
-        this.currentPage = currentPage
-        this.pageSize = pageSize
-        this.getData()
-      },
-      getPvData() {
-        this.$axios.get('/pvModuleModel/').then(res => {
-          this.pvInfo = res.data
-          this.pvInfoMode = []
-          for (let i = 0; i < this.pvInfo.length; i++) {
-            const pInfo = {label: this.pvInfo[i].model, value: this.pvInfo[i].id}
-            this.pvInfoMode.push(pInfo)
-          }
-          console.log("获取所有光伏组件信息成功")
-        }).catch((error) => {
-          this.$message.error('获取逆变器信息出错' + error)
-        })
-      },
-      timestampToTime(time) {
-        const date = new Date(time) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
-        const Y = date.getFullYear() + '-'
-        const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
-        const D = date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()
-        return Y + M + D
-      },
-      getSelectionEvent() {
-        let selectRecords = this.$refs.xTable.getCheckboxRecords()
-        if(selectRecords==""){
-          this.$message.error('请选择要删除的对象')
-          return
+    getPvData() {
+      this.$axios.get('/pvModuleModel/').then(res => {
+        this.pvInfo = res.data
+        this.pvInfoMode = []
+        for (let i = 0; i < this.pvInfo.length; i++) {
+          const pInfo = {label: this.pvInfo[i].model, value: this.pvInfo[i].id}
+          this.pvInfoMode.push(pInfo)
         }
-        this.rowId = ''
-        for (let i = 0; i < selectRecords.length; i++)
-          this.rowId += (selectRecords[i].id + ",")
-        // console.log(this.rowId)
-        this.delVisible = true
-      },
-      piInsertEvent(row) {
-        this.piadd = true;
-        this.showTable = true
-        this.isEdit = false;
-        this.loadButton = true;
-        this.$refs.xTable.insert({interval: 60}).then(({row}) => this.$refs.xTable.setActiveRow(row))
-      },
-      insertEvent(row) {
-        this.id = ''
-        this.showTable = true
-        this.piadd = false;
-        this.isEdit = false;
-        this.loadButton = true;
-        this.$refs.xTable.insert({interval: 60}).then(({row}) => this.$refs.xTable.setActiveRow(row))
-      },
-      async insertBatchEvent(row) {
-        /*const { row: newRow } = await this.$refs.bTable.insert()*/
-        // alert(1111)
-        // 插入一条数据并触发校验
-        let {row: newRow} = await this.$refs.bTable.insertAt(row)
-        await this.$refs.bTable.setActiveRow(newRow)
-        // alert(2222)
-        /*          const errMap = await this.$refs.bTable.validate(newRow).catch(errMap => errMap)
-                  if (errMap) {
+        console.log("获取所有光伏组件信息成功")
+      }).catch((error) => {
+        this.$message.error('获取逆变器信息出错' + error)
+      })
+    },
+    timestampToTime(time) {
+      const date = new Date(time) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
+      const Y = date.getFullYear() + '-'
+      const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
+      const D = date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()
+      return Y + M + D
+    },
+    getSelectionEvent() {
+      let selectRecords = this.$refs.xTable.getCheckboxRecords()
+      if (selectRecords == "") {
+        this.$message.error('请选择要删除的对象')
+        return
+      }
+      this.rowId = ''
+      for (let i = 0; i < selectRecords.length; i++)
+        this.rowId += (selectRecords[i].id + ",")
+      // console.log(this.rowId)
+      this.delVisible = true
+    },
+    piInsertEvent(row) {
+      this.piadd = true;
+      this.showTable = true
+      this.isEdit = false;
+      this.loadButton = true;
+      this.$refs.xTable.insert({interval: 60}).then(({row}) => this.$refs.xTable.setActiveRow(row))
+    },
+    insertEvent(row) {
+      this.id = ''
+      this.showTable = true
+      this.piadd = false;
+      this.isEdit = false;
+      this.loadButton = true;
+      this.$refs.xTable.insert({interval: 60}).then(({row}) => this.$refs.xTable.setActiveRow(row))
+    },
+    async insertBatchEvent(row) {
+      /*const { row: newRow } = await this.$refs.bTable.insert()*/
+      // alert(1111)
+      // 插入一条数据并触发校验
+      let {row: newRow} = await this.$refs.bTable.insertAt(row)
+      await this.$refs.bTable.setActiveRow(newRow)
+      // alert(2222)
+      /*          const errMap = await this.$refs.bTable.validate(newRow).catch(errMap => errMap)
+                if (errMap) {
 
-                  }*/
-      },
-      async fullValidEvent() {
-        const errMap = await this.$refs.bTable.fullValidate().catch(errMap => errMap)
-        if (errMap) {
-          let msgList = []
-          Object.values(errMap).forEach(errList => {
-            errList.forEach(params => {
-              let {rowIndex, column, rules} = params
-              rules.forEach(rule => {
-                msgList.push(`第 ${rowIndex} 行 ${column.title} 校验错误:${rule.message}`)
-              })
+                }*/
+    },
+    async fullValidEvent() {
+      const errMap = await this.$refs.bTable.fullValidate().catch(errMap => errMap)
+      if (errMap) {
+        let msgList = []
+        Object.values(errMap).forEach(errList => {
+          errList.forEach(params => {
+            let {rowIndex, column, rules} = params
+            rules.forEach(rule => {
+              msgList.push(`第 ${rowIndex} 行 ${column.title} 校验错误:${rule.message}`)
             })
           })
-          this.$XModal.message({
-            status: 'error',
-            message: () => {
-              return [
-                < div
-            class
-              = "red"
-              style = "max-height: 400px;overflow: auto;" >
+        })
+        this.$XModal.message({
+          status: 'error',
+          message: () => {
+            return [
+              < div
+                class
+                  ="red"
+                style="max-height: 400px;overflow: auto;">
                 {
-                  msgList.map(msg => < div > {msg} < /div>)
+                  msgList.map(msg => < div> {msg} < /div>)
                 }
-                < /div>
+              < /div>
             ]
-            }
-          })
-        } else {
-          this.$XModal.message({status: 'success', message: '校验成功!'})
-        }
-      },
-      saveBatchEvent() {
-        const {insertRecords, removeRecords, updateRecords} = this.$refs.bTable.getRecordset()
-        this.$XModal.alert(`insertRecords=${insertRecords.length} removeRecords=${removeRecords.length} updateRecords=${updateRecords.length}`)
-      },
-      editRowEvent(row) {
-        this.id = row.id
-        for (let i = 0; i < this.pvInfoMode.length; i++) {
-          if (row.batteryModel == this.pvInfoMode[i].value) {
-            row.batteryModel = this.pvInfoMode[i].value
           }
+        })
+      } else {
+        this.$XModal.message({status: 'success', message: '校验成功!'})
+      }
+    },
+    saveBatchEvent() {
+      const {insertRecords, removeRecords, updateRecords} = this.$refs.bTable.getRecordset()
+      this.$XModal.alert(`insertRecords=${insertRecords.length} removeRecords=${removeRecords.length} updateRecords=${updateRecords.length}`)
+    },
+    editRowEvent(row) {
+      this.id = row.id
+      for (let i = 0; i < this.pvInfoMode.length; i++) {
+        if (row.batteryModel == this.pvInfoMode[i].value) {
+          row.batteryModel = this.pvInfoMode[i].value
         }
-        this.isEdit = true
-        this.loadButton = true
-        this.$refs.xTable.setActiveRow(row)
-      },
-      //设计有判断是否批量添加,批量添加弹窗表明添加条数,然后批量生成保存
-      editSave(row) {
-        this.$refs.xTable.validate(this.$refs.xTable.getCurrentRecord(),valid => {
+      }
+      this.isEdit = true
+      this.loadButton = true
+      this.$refs.xTable.setActiveRow(row)
+    },
+    //设计有判断是否批量添加,批量添加弹窗表明添加条数,然后批量生成保存
+    editSave(row) {
+      this.$refs.xTable.validate(this.$refs.xTable.getCurrentRecord(), valid => {
 
-          if (valid) {
-            if (this.piadd) {
-              const inviter = row
-              this.$prompt('请输入开始编号(例:1-0,其中0为开始值)', '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                inputType: 'number',
-              }).then(({value}) => {
-                const startValue = value
-                if (startValue >= 0 && startValue != null) {
-                  this.$prompt('请输入添加数目', '提示', {
-                    confirmButtonText: '确定',
-                    cancelButtonText: '取消',
-                    inputType: 'number',
-                  }).then(({value}) => {
-                    const endValue = value
-                    if (endValue >= 0) {
-                      this.$axios.post('/inverterInfo/saveAll/' + startValue + '/' + endValue, row).then(res => {
-                        this.$message({
-                          message: '保存成功',
-                          type: 'success'
-                        })
-                        this.loadButton = false
-                        this.piadd = false
-                        this.getData()
-                      }).catch((error) => {
-                        this.$refs.xTable.setActiveRow(row)
-                        this.$message.error('保存逆变器出错' + error)
+        if (valid) {
+          if (this.piadd) {
+            const inviter = row
+            this.$prompt('请输入开始编号(例:1-0,其中0为开始值)', '提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              inputType: 'number',
+            }).then(({value}) => {
+              const startValue = value
+              if (startValue >= 0 && startValue != null) {
+                this.$prompt('请输入添加数目', '提示', {
+                  confirmButtonText: '确定',
+                  cancelButtonText: '取消',
+                  inputType: 'number',
+                }).then(({value}) => {
+                  const endValue = value
+                  if (endValue >= 0) {
+                    this.$axios.post('/inverterInfo/saveAll/' + startValue + '/' + endValue, row).then(res => {
+                      this.$message({
+                        message: '保存成功',
+                        type: 'success'
                       })
-                    } else {
-                      alert("数量必须是正整数")
-                    }
-                  })
-                } else {
-                  alert("开始值必须是正整数并且不能为空")
-                }
-              })
-            } else {
-              this.$refs.xTable.clearActived().then(() => {
-                if (this.isEdit) {
-                  row.equipmentType = row.equipmentType.code
-                  //编辑保存
-                  this.$axios.put('/inverterInfo/', row).then(res => {
-                    this.$message({
-                      message: '修改成功',
-                      type: 'success'
+                      this.loadButton = false
+                      this.piadd = false
+                      this.getData()
+                    }).catch((error) => {
+                      this.$refs.xTable.setActiveRow(row)
+                      this.$message.error('保存逆变器出错' + error)
                     })
-                    this.loadButton = false;
-                    this.getData()
-                  }).catch((error) => {
-                    this.$refs.xTable.setActiveRow(row)
-                    this.$message.error('修改逆变器出错' + error)
+                  } else {
+                    alert("数量必须是正整数")
+                  }
+                })
+              } else {
+                alert("开始值必须是正整数并且不能为空")
+              }
+            })
+          } else {
+            this.$refs.xTable.clearActived().then(() => {
+              if (this.isEdit) {
+                row.equipmentType = row.equipmentType.code
+                //编辑保存
+                this.$axios.put('/inverterInfo/', row).then(res => {
+                  this.$message({
+                    message: '修改成功',
+                    type: 'success'
                   })
-                } else {
-                  //新增保存
-                  this.$axios.post('/inverterInfo/', row).then(res => {
-                    this.$message({
-                      message: '保存成功',
-                      type: 'success'
-                    })
-                    this.loadButton = false;
-                    this.getData()
-                  }).catch((error) => {
-                    this.$refs.xTable.setActiveRow(row)
-                    this.$message.error('保存逆变器出错' + error)
+                  this.loadButton = false;
+                  this.getData()
+                }).catch((error) => {
+                  this.$refs.xTable.setActiveRow(row)
+                  this.$message.error('修改逆变器出错' + error)
+                })
+              } else {
+                //新增保存
+                this.$axios.post('/inverterInfo/', row).then(res => {
+                  this.$message({
+                    message: '保存成功',
+                    type: 'success'
                   })
-                }
-              })
-            }
-          } else {
-            this.$XModal.message({status: 'error', message: '校验不通过!'})
-          }
-        })
-      },
-      cancelRowEvent(row) {
-        const xTable = this.$refs.xTable
-        xTable.clearActived().then(() => {
-          // 还原行数据
-          if (this.isEdit) {
-            //编辑
-            xTable.revertData(row)
-          } else {
-            //新增
-            xTable.remove(row)
+                  this.loadButton = false;
+                  this.getData()
+                }).catch((error) => {
+                  this.$refs.xTable.setActiveRow(row)
+                  this.$message.error('保存逆变器出错' + error)
+                })
+              }
+            })
           }
-          this.loadButton = false;
+        } else {
+          this.$XModal.message({status: 'error', message: '校验不通过!'})
+        }
+      })
+    },
+    cancelRowEvent(row) {
+      const xTable = this.$refs.xTable
+      xTable.clearActived().then(() => {
+        // 还原行数据
+        if (this.isEdit) {
+          //编辑
+          xTable.revertData(row)
+        } else {
+          //新增
+          xTable.remove(row)
+        }
+        this.loadButton = false;
+      })
+    },
+    // 删除场站信息
+    deleteRowEvent(row) {
+      this.rowId = row.id
+      this.delVisible = true
+    },
+    deleteCancel() {
+      this.delVisible = false
+    },
+    deleteInfo() {
+      this.$axios.delete('/inverterInfo/' + '' + this.rowId).then(res => {
+        this.$message({
+          message: '删除成功',
+          type: 'success'
         })
-      },
-      // 删除场站信息
-      deleteRowEvent(row) {
-        this.rowId = row.id
-        this.delVisible = true
-      },
-      deleteCancel() {
         this.delVisible = false
-      },
-      deleteInfo() {
-        this.$axios.delete('/inverterInfo/' + '' + this.rowId).then(res => {
-          this.$message({
-            message: '删除成功',
-            type: 'success'
-          })
-          this.delVisible = false
-          this.getData()
-        }).catch((error) => {
-          this.$message.error('删除逆变器信息出错' + error)
-        })
-      },
-      exportDataEvent() {
-        // this.loading = true
-        this.$axios.get('/inverterInfo/').then(res => {
-          const data = res.data.content
-          this.$refs.xTable.exportData({
-            filename: '逆变器信息',
-            type: 'csv',
-            isHeader: true,
-            isFooter: true,
-            data
-          })
-          // this.loading = false
-        }).catch(e => {
-          // this.loading = false
+        this.getData()
+      }).catch((error) => {
+        this.$message.error('删除逆变器信息出错' + error)
+      })
+    },
+    exportDataEvent() {
+      // this.loading = true
+      this.$axios.get('/inverterInfo/').then(res => {
+        const data = res.data.content
+        this.$refs.xTable.exportData({
+          filename: '逆变器信息',
+          type: 'csv',
+          isHeader: true,
+          isFooter: true,
+          data
         })
-      },
-      /*dataUpload(item) {
+        // this.loading = false
+      }).catch(e => {
+        // this.loading = false
+      })
+    },
+    /*dataUpload(item) {
 
-      },*/
-      importDataEvent(item) {
-        this.loadButton = true
-        const formData = new FormData()
-        formData.append('file', item.file)
-        // console.log('上传文件', item.file)
-        this.$axios.post('/console/importPvModuleModelCsv/', formData).then(res => {
-          this.$message({
-            message: '导入光伏组件信息成功',
-            type: 'success'
-          })
-        }).catch((error) => {
-          this.$message({
-            message: '导入光伏组件信息成功',
-            type: 'success'
-          })
+    },*/
+    importDataEvent(item) {
+      this.loadButton = true
+      const formData = new FormData()
+      formData.append('file', item.file)
+      // console.log('上传文件', item.file)
+      this.$axios.post('/console/importPvModuleModelCsv/', formData).then(res => {
+        this.$message({
+          message: '导入光伏组件信息成功',
+          type: 'success'
+        })
+      }).catch((error) => {
+        this.$message({
+          message: '导入光伏组件信息成功',
+          type: 'success'
         })
-        this.loadButton = false
-        /*  this.$refs.xTable.importData({ types: ['csv'] })*/
-      },
+      })
+      this.loadButton = false
+      /*  this.$refs.xTable.importData({ types: ['csv'] })*/
+    },
 
 
-    }
   }
+}
 </script>
 
 <style scoped>
 
-  .my_table_insert .vxe-body--row.is--new {
-    background-color: #f1fdf1;
-  }
+.my_table_insert .vxe-body--row.is--new {
+  background-color: #f1fdf1;
+}
 </style>

+ 6 - 0
ipfcst-console/src/main/frontend/views/console/weatherStationInfo/index.vue

@@ -42,6 +42,8 @@
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="name" title="名称"width="13%"
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
+            <vxe-table-column field="equipmentNo" title="设备编号"width="13%"
+                              :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="manufacturer" title="生产商" width="13%"
                               :edit-render="{name: '$input', attrs: {type: 'text'}}"></vxe-table-column>
             <vxe-table-column field="modelNumber" title="型号" width="13%"
@@ -182,6 +184,9 @@
           name: [
             {required: true, validator:checkName},
           ],
+          equipmentNo: [
+            {required: true, message: '设备编号不能为空'},
+          ],
           manufacturer: [
             {required: true, message: '制造商名称不能为空'},
           ],
@@ -205,6 +210,7 @@
     },
     created() {
       this.getStationList()
+      this.queryInfo()
     },
     methods: {
       // 查询

+ 0 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/config/RedisConfig.java

@@ -3,7 +3,6 @@ package com.jiayue.ipfcst.config;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
 import redis.clients.jedis.JedisPool;
 import redis.clients.jedis.JedisPoolConfig;
 

+ 17 - 348
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ElectricFieldController.java

@@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -41,45 +42,6 @@ public class ElectricFieldController {
   @Autowired
   OverHaulPlanService overHaulPlanService;
 
-   /* @Autowired
-    InverterInfoService inverterInfoService;
-
-    @Autowired
-    WeatherStationInfoService weatherStationInfoService;
-
-    @Autowired
-    WindTowerInfoService windTowerInfoService;
-
-    @Autowired
-    WindTurbineInfoService windTurbineInfoService;
-
-    @Autowired
-    PvModuleModelService pvModuleModelService;
-
-    @Autowired
-    UploadObjectService uploadObjectService;
-
-    @Autowired
-    UploadFileChannelService uploadFileChannelService;
-
-    @Autowired
-    UploadFileCodeService uploadFileCodeService;
-
-    @Autowired
-    UploadURLService uploadURLService;
-
-    @Autowired
-    TunnelInfoService tunnelInfoService;
-
-    @Autowired
-    EquipmentAttributeService equipmentAttributeService;
-
-    @Autowired
-    ProtocolSenderDataPointService protocolSenderDataPointService;
-
-    @Autowired
-    ProtocolGatherDataPointService protocolGatherDataPointService;*/
-
   /**
    * 新增场站信息
    *
@@ -97,10 +59,8 @@ public class ElectricFieldController {
       log.error(" 保存场站信息异常");
       return ResponseVO.fail();
     }
-
   }
 
-
   /**
    * 更新场站信息
    *
@@ -118,7 +78,6 @@ public class ElectricFieldController {
       log.error(" 更新场站信息异常");
       return ResponseVO.fail();
     }
-
   }
 
   /**
@@ -126,7 +85,6 @@ public class ElectricFieldController {
    *
    * @return 所有场站信息
    */
-
   @GetMapping(value = "/getElectricField")
   public ResponseVO getElectricField() {
     try {
@@ -137,7 +95,6 @@ public class ElectricFieldController {
       log.error(" 获取场站信息异常");
       return ResponseVO.success(null);
     }
-
   }
 
   /**
@@ -145,7 +102,6 @@ public class ElectricFieldController {
    *
    * @return 所有场站信息
    */
-
   @GetMapping(value = "/getElectricField/{stationCode}")
   public ResponseVO getElectricFieldByStationCode(@PathVariable String stationCode) {
     try {
@@ -156,10 +112,8 @@ public class ElectricFieldController {
       log.error(" 获取场站信息异常");
       return ResponseVO.success(null);
     }
-
   }
 
-
   @DeleteMapping(value = "/{stationCode}")
   @SaveValidate
   public ResponseVO deleteElectricField(@PathVariable String stationCode) {
@@ -171,7 +125,6 @@ public class ElectricFieldController {
       log.error(" 删除场站信息异常");
       return ResponseVO.fail();
     }
-
   }
 
   /**
@@ -201,288 +154,8 @@ public class ElectricFieldController {
       log.error(" 获取场站类型异常");
       return ResponseVO.fail(elType);
     }
-
   }
 
-
-
-
-    /*@PostMapping(value = "/dataDownload")
-    public void dataDownload(HttpServletRequest request,
-                             HttpServletResponse response) {
-        BufferedOutputStream bos = null;
-        try {
-            response.setCharacterEncoding("UTF-8");
-            StringBuilder templateContent = new StringBuilder();
-            ElectricField electricField = electricFieldService.getElectricField();
-            // 添加第一行
-            String header = electricField.getStationCode();
-            templateContent.append(header + "\r\n");
-
-            List<String> vals = new ArrayList<>();
-            String val;
-            String type = "All";
-            List<ElectricField> electricFields = new ArrayList<>();
-            electricFields.add(electricField);
-            val = "ElectricField:::" + JsonBeanUtil.beanToJson(electricFields);
-            templateContent.append(val + "\r\n");
-
-            if (type.equals("All")) {
-                List<PvModuleModel> beans = pvModuleModelService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (PvModuleModel bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "PvModuleModel:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                List<OverhaulPlan> beans = overHaulPlanService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (OverhaulPlan bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "OverhaulPlan:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                List<InverterInfo> beans = inverterInfoService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (InverterInfo bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "InverterInfo:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                List<WeatherStationInfo> beans = weatherStationInfoService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (WeatherStationInfo bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "WeatherStationInfo:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                List<WindTowerInfo> beans = windTowerInfoService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (WindTowerInfo bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "WindTowerInfo:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                List<WindTurbineInfo> beans = windTurbineInfoService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (WindTurbineInfo bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "WindTurbineInfo:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-
-            if (type.equals("All")) {
-                List<SysParameter> beans = sysParameterService.getAll();
-                if (null != beans && beans.size() > 0) {
-                    for (SysParameter bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "SysParameter:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            if (type.equals("All")) {
-                //文件上报部分
-                List<UploadObject> beans = uploadObjectService.get();
-                if (null != beans && beans.size() > 0) {
-                    for (UploadObject bean : beans) {
-                        bean.setStationCode(header);
-                    }
-                    val = "UploadObject:::" + JsonBeanUtil.beanToJson(beans);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<UploadFileChannel> uploadFileChannels = uploadFileChannelService.get();
-                if (null != uploadFileChannels && uploadFileChannels.size() > 0) {
-                    for (UploadFileChannel bean : uploadFileChannels) {
-                        bean.setStationCode(header);
-                    }
-                    val = "UploadFileChannel:::" + JsonBeanUtil.beanToJson(uploadFileChannels);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<UploadFileCode> uploadFileCodes = uploadFileCodeService.get();
-                if (null != uploadFileCodes && uploadFileCodes.size() > 0) {
-                    for (UploadFileCode bean : uploadFileCodes) {
-                        bean.setStationCode(header);
-                    }
-                    val = "UploadFileCode:::" + JsonBeanUtil.beanToJson(uploadFileCodes);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<UploadURL> uploadURLS = uploadURLService.findAll();
-                if (null != uploadURLS && uploadURLS.size() > 0) {
-                    for (UploadURL bean : uploadURLS) {
-                        bean.setStationCode(header);
-                    }
-                    val = "UploadURL:::" + JsonBeanUtil.beanToJson(uploadURLS);
-                    templateContent.append(val + "\r\n");
-                }
-
-
-                //数据接入部分
-                List<EquipmentAttribute> equipmentAttributes = equipmentAttributeService.getAll();
-                if (null != equipmentAttributes && equipmentAttributes.size() > 0) {
-                    for (EquipmentAttribute bean : equipmentAttributes) {
-                        bean.setStationCode(header);
-                    }
-                    val = "EquipmentAttribute:::" + JsonBeanUtil.beanToJson(equipmentAttributes);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<FileParseTunnelInfo> fileParseTunnelInfos = tunnelInfoService.getAllFileParseTunnel();
-                if (null != fileParseTunnelInfos && fileParseTunnelInfos.size() > 0) {
-                    for (FileParseTunnelInfo bean : fileParseTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "FileParseTunnelInfo:::" + JsonBeanUtil.beanToJson(fileParseTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<Gather104TcpTunnelInfo> gather104TcpTunnelInfos = tunnelInfoService.getAllGather104TcpTunnel();
-                if (null != gather104TcpTunnelInfos && gather104TcpTunnelInfos.size() > 0) {
-                    for (Gather104TcpTunnelInfo bean : gather104TcpTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "Gather104TcpTunnelInfo:::" + JsonBeanUtil.beanToJson(gather104TcpTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<GatherCdtRtuTunnelInfo> gatherCdtRtuTunnelInfos = tunnelInfoService.getAllGatherCdtRtuTunnel();
-                if (null != gatherCdtRtuTunnelInfos && gatherCdtRtuTunnelInfos.size() > 0) {
-                    for (GatherCdtRtuTunnelInfo bean : gatherCdtRtuTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "GatherCdtRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherCdtRtuTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<GatherModbusRtuTunnelInfo> gatherModbusRtuTunnelInfos =
-                        tunnelInfoService.getAllGatherModbusRtuTunnel();
-                if (null != gatherModbusRtuTunnelInfos && gatherModbusRtuTunnelInfos.size() > 0) {
-                    for (GatherModbusRtuTunnelInfo bean : gatherModbusRtuTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "GatherModbusRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherModbusRtuTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<GatherModbusTcpTunnelInfo> gatherModbusTcpTunnelInfos =
-                        tunnelInfoService.getAllGatherModbusTcpTunnel();
-                if (null != gatherModbusTcpTunnelInfos && gatherModbusTcpTunnelInfos.size() > 0) {
-                    for (GatherModbusTcpTunnelInfo bean : gatherModbusTcpTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "GatherModbusTcpTunnelInfo:::" + JsonBeanUtil.beanToJson(gatherModbusTcpTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<Sender104TcpTunnelInfo> sender104TcpTunnelInfos = tunnelInfoService.getAllSender104TcpTunnel();
-                if (null != sender104TcpTunnelInfos && sender104TcpTunnelInfos.size() > 0) {
-                    for (Sender104TcpTunnelInfo bean : sender104TcpTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "Sender104TcpTunnelInfo:::" + JsonBeanUtil.beanToJson(sender104TcpTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<SenderCdtRtuTunnelInfo> senderCdtRtuTunnelInfos = tunnelInfoService.getAllSenderCdtRtuTunnel();
-                if (null != senderCdtRtuTunnelInfos && senderCdtRtuTunnelInfos.size() > 0) {
-                    for (SenderCdtRtuTunnelInfo bean : senderCdtRtuTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "SenderCdtRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(senderCdtRtuTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<SenderModbusRtuTunnelInfo> senderModbusRtuTunnelInfos =
-                        tunnelInfoService.getAllSenderModbusRtuTunnel();
-                if (null != senderModbusRtuTunnelInfos && senderModbusRtuTunnelInfos.size() > 0) {
-                    for (SenderModbusRtuTunnelInfo bean : senderModbusRtuTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "SenderModbusRtuTunnelInfo:::" + JsonBeanUtil.beanToJson(senderModbusRtuTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<SenderModbusTcpTunnelInfo> senderModbusTcpTunnelInfos =
-                        tunnelInfoService.getAllSenderModbusTcpTunnel();
-                if (null != senderModbusTcpTunnelInfos && senderModbusTcpTunnelInfos.size() > 0) {
-                    for (SenderModbusTcpTunnelInfo bean : senderModbusTcpTunnelInfos) {
-                        bean.setStationCode(header);
-                    }
-                    val = "SenderModbusTcpTunnelInfo:::" + JsonBeanUtil.beanToJson(senderModbusTcpTunnelInfos);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<ProtocolSenderDataPoint> protocolSenderDataPoints = protocolSenderDataPointService.get();
-                if (null != protocolSenderDataPoints && protocolSenderDataPoints.size() > 0) {
-                    for (ProtocolSenderDataPoint bean : protocolSenderDataPoints) {
-                        bean.setStationCode(header);
-                    }
-                    val = "ProtocolSenderDataPoint:::" + JsonBeanUtil.beanToJson(protocolSenderDataPoints);
-                    templateContent.append(val + "\r\n");
-                }
-
-                List<ProtocolGatherDataPoint> protocolGatherDataPoints = protocolGatherDataPointService.getAll();
-                if (null != protocolGatherDataPoints && protocolGatherDataPoints.size() > 0) {
-                    for (ProtocolGatherDataPoint bean : protocolGatherDataPoints) {
-                        bean.setStationCode(header);
-                    }
-                    val = "ProtocolGatherDataPoint:::" + JsonBeanUtil.beanToJson(protocolGatherDataPoints);
-                    templateContent.append(val + "\r\n");
-                }
-            }
-
-            byte[] templateContentBytes = templateContent.toString().getBytes("UTF-8");
-            long fileLength = templateContentBytes.length + 3;
-            response.setContentType("application/x-msdownload;charset=UTF-8");
-
-
-            response.setHeader("Content-disposition",
-                    "attachment; filename=" + URLEncoder.encode(electricField.getStationCode() + "-" + DateUtil.today() + ".rb", "UTF-8"));
-            response.setHeader("Content-Length", String.valueOf(fileLength));
-            bos = new BufferedOutputStream(response.getOutputStream());
-            bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
-            bos.write(templateContentBytes);
-            response.flushBuffer();
-        } catch (Exception e) {
-            log.error("系统错误:" + e.getMessage(), e);
-            throw new RuntimeException(e);
-        } finally {
-            if (bos != null)
-                try {
-                    bos.close();
-                } catch (IOException e) {
-                    log.error("系统错误:" + e.getMessage(), e);
-                }
-        }
-    }*/
-
   //导出所有场站
   @RequestMapping(value = "/export")
   public void export(HttpServletResponse response) {
@@ -495,33 +168,31 @@ public class ElectricFieldController {
 
       StringBuilder content = new StringBuilder();
       for (ElectricField electricField : electricFieldList) {
-        content.append(electricField.getStationCode() + ",");
-        content.append(electricField.getName() + ",");
-        content.append(electricField.getSign() + ",");
-        content.append(electricField.getNetSubstationName() + ",");
-        content.append(electricField.getCapacity() + ",");
-        content.append(electricField.getGridCE() + ",");
-        content.append(electricField.getLongitude() + ",");
-        content.append(electricField.getLatitude() + ",");
-        content.append(electricField.getElectricFieldTypeEnum().getMessage() + ",");
-        content.append(electricField.getInterval() + ",");
-        content.append(electricField.getAltitude() + ",");
-        content.append(electricField.getCompany() + ",");
-        content.append(electricField.getLocation() + ",");
-        content.append(electricField.getArea() + ",");
+        content.append(electricField.getStationCode()).append(",");
+        content.append(electricField.getName()).append(",");
+        content.append(electricField.getSign()).append(",");
+        content.append(electricField.getNetSubstationName()).append(",");
+        content.append(electricField.getCapacity()).append(",");
+        content.append(electricField.getGridCE()).append(",");
+        content.append(electricField.getLongitude()).append(",");
+        content.append(electricField.getLatitude()).append(",");
+        content.append(electricField.getElectricFieldTypeEnum().getMessage()).append(",");
+        content.append(electricField.getInterval()).append(",");
+        content.append(electricField.getAltitude()).append(",");
+        content.append(electricField.getCompany()).append(",");
+        content.append(electricField.getLocation()).append(",");
+        content.append(electricField.getArea()).append(",");
         content.append("\r\n");
       }
       templateContent.append(header);
-      templateContent.append(content.toString());
+      templateContent.append(content);
       response.setContentType("application/x-msdownload;charset=UTF-8");// 文件下载必须配置为application/x-msdownload
       response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("场站信息数据.csv", "UTF-8"));// 中文文件名必须使用URLEncoder.encode进行转码
-      byte[] templateContentBytes = templateContent.toString().getBytes("UTF-8");
+      byte[] templateContentBytes = templateContent.toString().getBytes(StandardCharsets.UTF_8);
       bos = new BufferedOutputStream(response.getOutputStream());// 向response中写入文件流
       bos.write(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});// 指定csv文件用UTF-8字符集打开
       bos.write(templateContentBytes);
       response.flushBuffer();
-      templateContent = null;
-
     } catch (Exception e) {
       log.error("系统错误:" + e.getMessage(), e);
       throw new RuntimeException(e);
@@ -533,7 +204,5 @@ public class ElectricFieldController {
           log.error("系统错误:" + e.getMessage(), e);
         }
     }
-
   }
-
 }

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

@@ -18,7 +18,7 @@ public class FileAnalysisRecordController {
 
   @GetMapping("/FileAnalysisRecord/{startTime}")
   public ResponseVO findByCreateTimeBetween(@PathVariable Long startTime) {
-    List<FileAnalysisRecord> fileAnalysisRecords = fileAnalysisRecordService.findByCreateTimeBetween(new Date(startTime), new Date(startTime + 86400000l));
+    List<FileAnalysisRecord> fileAnalysisRecords = fileAnalysisRecordService.findByCreateTimeBetween(new Date(startTime), new Date(startTime + 86400000L));
     return ResponseVO.success(fileAnalysisRecords);
   }
 }

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

@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -34,7 +33,7 @@ public class ForecastPowerShortTermController {
   @GetMapping(value = "/forecastPowerShortTerm/{startTime}/{endTime}/{stationCode}")
   public ResponseVO findByForecastTimeBetween(@PathVariable("startTime") Long startTime,
                                               @PathVariable("endTime") Long endTime, @PathVariable("stationCode") String stationCode) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = forecastPowerShortTermService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
       return ResponseVO.success(map);
@@ -61,7 +60,7 @@ public class ForecastPowerShortTermController {
                                                @PathVariable("page") Integer page,
                                                @PathVariable("size") Integer size,
                                                String sortOrder) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = forecastPowerShortTermService.findByTimeBetweenAndNoForPaging(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);

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

@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -38,7 +37,7 @@ public class ForecastPowerShortTermHisController {
                                               @PathVariable("page") Integer page,
                                               @PathVariable("size") Integer size,
                                               String sortOrder) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = forecastPowerShortTermHisService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);
@@ -47,6 +46,4 @@ public class ForecastPowerShortTermHisController {
       return ResponseVO.fail(e.toString());
     }
   }
-
-
 }

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

@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -39,7 +38,7 @@ public class ForecastPowerUltraShortTermHisController {
   public ResponseVO findByForecastTimeBetween(@PathVariable("startTime") Long startTime,
                                               @PathVariable("endTime") Long endTime,
                                               @PathVariable("endTime") Integer ago) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = forecastPowerUltraShortTermService.findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTime(startTime, endTime, ago);
       return ResponseVO.success(map);
@@ -58,7 +57,7 @@ public class ForecastPowerUltraShortTermHisController {
    */
   @GetMapping(value = "/findByForecastRealTimeUltraShortTerm16/{startTime}/{stationCode}")
   public ResponseVO findByForecastRealTimeUltraShortTerm16(@PathVariable("startTime") Long startTime, @PathVariable("stationCode") String stationCode) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = forecastPowerUltraShortTermService.findByForecastRealTimeUltraShortTerm16(startTime, stationCode);
       return ResponseVO.success(map);

+ 103 - 103
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/InverterInfoController.java

@@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -23,131 +22,132 @@ import java.util.List;
 @Slf4j
 public class InverterInfoController {
 
-    private final InverterInfoService inverterInfoService;
+  private final InverterInfoService inverterInfoService;
 
-    @Autowired
-    public InverterInfoController(InverterInfoService inverterInfoService) {
-        this.inverterInfoService = inverterInfoService;
-    }
-
-    /**
-     * 获取逆变器(分页)
-     *
-     * @return 执行结果
-     */
-    @GetMapping(value = {"inverterInfo/{page}/{size}/{stationCode}"})
-    public ResponseVO getPageAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) {
-      InverterInfo inverterInfo = new InverterInfo();
-      if (!"ALL".equals(stationCode)) {
-        inverterInfo.setStationCode(stationCode);
-      }
-      Page<InverterInfo> inverterPage = this.inverterInfoService.get(inverterInfo, page, size);
-      return ResponseVO.success(inverterPage);
-    }
+  @Autowired
+  public InverterInfoController(InverterInfoService inverterInfoService) {
+    this.inverterInfoService = inverterInfoService;
+  }
 
-    /**
-     * 获取逆变器
-     *
-     * @return 执行结果
-     */
-    @GetMapping(value = {"inverterInfo"})
-    public ResponseVO getAll() {
-      List<InverterInfo> list = this.inverterInfoService.getAll();
-      return ResponseVO.success(list);
+  /**
+   * 获取逆变器(分页)
+   *
+   * @return 执行结果
+   */
+  @GetMapping(value = {"inverterInfo/{page}/{size}/{stationCode}"})
+  public ResponseVO getPageAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) {
+    InverterInfo inverterInfo = new InverterInfo();
+    if (!"ALL".equals(stationCode)) {
+      inverterInfo.setStationCode(stationCode);
     }
+    Page<InverterInfo> inverterPage = this.inverterInfoService.get(inverterInfo, page, size);
+    return ResponseVO.success(inverterPage);
+  }
 
-    /**
-     * 保存逆变器信息
-     *
-     * @param inverterInfo 参数
-     * @return 执行结果
-     */
-    @SaveValidate
-    @PostMapping(value = "inverterInfo/")
-    public ResponseVO saveInverter(@RequestBody InverterInfo inverterInfo) {
-        try {
-            inverterInfoService.save(inverterInfo);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 保存逆变器信息异常");
-            return ResponseVO.fail();
-        }
+  /**
+   * 获取逆变器
+   *
+   * @return 执行结果
+   */
+  @GetMapping(value = {"inverterInfo"})
+  public ResponseVO getAll() {
+    List<InverterInfo> list = this.inverterInfoService.getAll();
+    return ResponseVO.success(list);
+  }
 
+  /**
+   * 保存逆变器信息
+   *
+   * @param inverterInfo 参数
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PostMapping(value = "inverterInfo/")
+  public ResponseVO saveInverter(@RequestBody InverterInfo inverterInfo) {
+    try {
+      inverterInfoService.save(inverterInfo);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 保存逆变器信息异常");
+      return ResponseVO.fail();
     }
 
-    /**
-     * 批量保存逆变器信息
-     *
-     * @param inverterInfo 参数
-     * @return 执行结果
-     */
-    @SaveValidate
-    @PostMapping(value = "inverterInfo/saveAll/{startValue}/{endValue}")
-    public ResponseVO allSaveInverter(@RequestBody InverterInfo inverterInfo,@PathVariable("startValue") Integer startValue,@PathVariable("endValue") Integer endValue) {
-        try {
-          inverterInfoService.addALL(inverterInfo,startValue,endValue);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 保存逆变器信息异常");
-            return ResponseVO.fail();
-        }
-    }
+  }
 
+  /**
+   * 批量保存逆变器信息
+   *
+   * @param inverterInfo 参数
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PostMapping(value = "inverterInfo/saveAll/{startValue}/{endValue}")
+  public ResponseVO allSaveInverter(@RequestBody InverterInfo inverterInfo, @PathVariable("startValue") Integer startValue, @PathVariable("endValue") Integer endValue) {
+    try {
+      inverterInfoService.addALL(inverterInfo, startValue, endValue);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 保存逆变器信息异常");
+      return ResponseVO.fail();
+    }
+  }
 
-    /**
-     * 更新逆变器信息
-     *
-     * @param inverterInfo 参数
-     * @return 执行结果
-     */
-    @SaveValidate
-    @PutMapping(value = "inverterInfo/")
-    public ResponseVO updateInverter(@RequestBody InverterInfo inverterInfo) {
-        try {
-            inverterInfoService.save(inverterInfo);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 更新逆变器信息异常");
-            return ResponseVO.fail();
-        }
 
+  /**
+   * 更新逆变器信息
+   *
+   * @param inverterInfo 参数
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PutMapping(value = "inverterInfo/")
+  public ResponseVO updateInverter(@RequestBody InverterInfo inverterInfo) {
+    try {
+      inverterInfoService.save(inverterInfo);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 更新逆变器信息异常");
+      return ResponseVO.fail();
     }
 
+  }
 
-    /**
-     * 删除逆变器信息
-     *
-     * @param ids 删除id
-     * @return 执行结果
-     */
-    @SaveValidate
-    @DeleteMapping(value = "inverterInfo/{ids}")
-    public ResponseVO deleteInverter(@PathVariable("ids") String ids) {
-        try {
-            inverterInfoService.delete(ids);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 删除逆变器异常");
-            return ResponseVO.fail();
-        }
 
+  /**
+   * 删除逆变器信息
+   *
+   * @param ids 删除id
+   * @return 执行结果
+   */
+  @SaveValidate
+  @DeleteMapping(value = "inverterInfo/{ids}")
+  public ResponseVO deleteInverter(@PathVariable("ids") String ids) {
+    try {
+      inverterInfoService.delete(ids);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 删除逆变器异常");
+      return ResponseVO.fail();
     }
 
+  }
+
   /**
    * 查询所有逆变器设备信息按ID排序 yh
+   *
    * @return 结果集
    */
   @GetMapping(value = "findInverterInfoByStation/{stationCode}")
-  public ResponseVO findInverterInfoByStation(@PathVariable("stationCode") String stationCode){
-    List<InverterInfo> list = new ArrayList<>();
-    try{
+  public ResponseVO findInverterInfoByStation(@PathVariable("stationCode") String stationCode) {
+    List<InverterInfo> list;
+    try {
       list = inverterInfoService.getByStationCode(stationCode);
       return ResponseVO.success(list);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("逆变器信息所有查询错误");
       return ResponseVO.fail(e.toString());

+ 10 - 21
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/InverterStatusDataController.java

@@ -1,47 +1,36 @@
 package com.jiayue.ipfcst.console.controller;
 
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
-import com.jiayue.ipfcst.common.data.entity.InverterStatusData;
-import com.jiayue.ipfcst.console.service.InverterInfoService;
 import com.jiayue.ipfcst.console.service.InverterStatusDataService;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.Date;
+import java.util.Map;
 
 @RestController
 @Slf4j
 public class InverterStatusDataController {
 
   private final InverterStatusDataService inverterStatusDataService;
-  private final InverterInfoService inverterInfoService;
 
   @Autowired
-  public InverterStatusDataController(InverterStatusDataService inverterStatusDataService, InverterInfoService inverterInfoService) {
+  public InverterStatusDataController(InverterStatusDataService inverterStatusDataService) {
     this.inverterStatusDataService = inverterStatusDataService;
-    this.inverterInfoService = inverterInfoService;
   }
 
 
   /**
    * 分页查询 所有逆变器功率状态
    *
-   * @param startTime     开始时间
-   * @param endTime       结束时间
-   * @param page          页码
-   * @param size          条数
-   * @param no            逆变器编号
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @param page      页码
+   * @param size      条数
+   * @param no        逆变器编号
    * @return
    */
   @GetMapping(value = "/inverterStatusData/{stationCode}/{startTime}/{endTime}/{page}/{size}/{no}")
@@ -51,9 +40,9 @@ public class InverterStatusDataController {
                                                @PathVariable("page") Integer page,
                                                @PathVariable("size") Integer size,
                                                @PathVariable("no") String no) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
-      map = inverterStatusDataService.findByTimeBetweenForPaging(stationCode,new Date(startTime), new Date(endTime), page, size, no);
+      map = inverterStatusDataService.findByTimeBetweenForPaging(stationCode, new Date(startTime), new Date(endTime), page, size, no);
       return ResponseVO.success(map);
     } catch (Exception e) {
       e.printStackTrace();

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

@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -39,7 +38,7 @@ public class NwpController {
   public ResponseVO findByForecastTimeBetween(@PathVariable("startTime") Long startTime,
                                               @PathVariable("endTime") Long endTime,
                                               @PathVariable("stationCode") String stationCode) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = nwpService.findByForecastTimeBetween(startTime, endTime, stationCode);
       return ResponseVO.success(map);
@@ -67,7 +66,7 @@ public class NwpController {
                                                @PathVariable("page") Integer page,
                                                @PathVariable("size") Integer size,
                                                String sortOrder) {
-    Map<String, Object> map = new HashMap<>();
+    Map<String, Object> map;
     try {
       map = nwpService.findByTimeBetweenAndNoForPaging(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);

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

@@ -100,7 +100,6 @@ public class OverHaulOlanController {
   @SneakyThrows
   @GetMapping()
   public ResponseVO getAll() {
-    OverhaulPlan overhaulPlan = new OverhaulPlan();
     List<OverhaulPlan> list = this.overHaulPlanService.getAll();
     return ResponseVO.success(list);
   }

+ 107 - 106
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PvModuleModelController.java

@@ -3,7 +3,6 @@ package com.jiayue.ipfcst.console.controller;
 import com.jiayue.ipfcst.aop.SaveValidate;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
 import com.jiayue.ipfcst.common.data.constant.enums.PvRotationModeEnum;
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.PvModuleModel;
 import com.jiayue.ipfcst.console.service.PvModuleModelService;
 import lombok.extern.slf4j.Slf4j;
@@ -27,139 +26,141 @@ import java.util.Map;
 @Slf4j
 public class PvModuleModelController {
 
-    private final PvModuleModelService pvModuleModelService;
-
-    @Autowired public PvModuleModelController(PvModuleModelService pvModuleModelService) {
-        this.pvModuleModelService = pvModuleModelService;
-    }
+  private final PvModuleModelService pvModuleModelService;
 
+  @Autowired
+  public PvModuleModelController(PvModuleModelService pvModuleModelService) {
+    this.pvModuleModelService = pvModuleModelService;
+  }
 
-    /**
-     * 分页获取光伏组件信息
-     * @param size 条数
-     * @param page 页码
-     * @return 光伏组件信息
-     */
 
-    @GetMapping(value="pvModuleModel/{page}/{size}/{stationCode}")
-    public ResponseVO getPvModuleModel(@PathVariable("page")  Integer page,
-                                       @PathVariable("size")  Integer size, @PathVariable("stationCode") String stationCode) {
-      PvModuleModel pvModuleModel = new PvModuleModel();
-      if (!"ALL".equals(stationCode)) {
-        pvModuleModel.setStationCode(stationCode);
-      }
+  /**
+   * 分页获取光伏组件信息
+   *
+   * @param size 条数
+   * @param page 页码
+   * @return 光伏组件信息
+   */
 
-      Page<PvModuleModel> pvModuleModelPage = this.pvModuleModelService.get(pvModuleModel, page, size);
-      return ResponseVO.success(pvModuleModelPage);
+  @GetMapping(value = "pvModuleModel/{page}/{size}/{stationCode}")
+  public ResponseVO getPvModuleModel(@PathVariable("page") Integer page,
+                                     @PathVariable("size") Integer size, @PathVariable("stationCode") String stationCode) {
+    PvModuleModel pvModuleModel = new PvModuleModel();
+    if (!"ALL".equals(stationCode)) {
+      pvModuleModel.setStationCode(stationCode);
     }
 
+    Page<PvModuleModel> pvModuleModelPage = this.pvModuleModelService.get(pvModuleModel, page, size);
+    return ResponseVO.success(pvModuleModelPage);
+  }
 
-    /**
-     * 获取光伏组件信息
-     *
-     * @return 光伏组件信息
-     */
 
-    @GetMapping(value="pvModuleModel/")
-    public ResponseVO getAll() {
+  /**
+   * 获取光伏组件信息
+   *
+   * @return 光伏组件信息
+   */
 
-        try{
-            List<PvModuleModel> ps =  this.pvModuleModelService.getAll();
+  @GetMapping(value = "pvModuleModel/")
+  public ResponseVO getAll() {
 
-            return ResponseVO.success(ps);
-        }catch (Exception e){
-            e.printStackTrace();
-            log.error(" 获取所有光伏组件异常");
-            return ResponseVO.success(null);
-        }
+    try {
+      List<PvModuleModel> ps = this.pvModuleModelService.getAll();
 
+      return ResponseVO.success(ps);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取所有光伏组件异常");
+      return ResponseVO.success(null);
     }
 
-    /**
-     * 保存光伏组件信息
-     *
-     * @param pvModuleModel 参数
-     * @return 执行结果
-     */
-    @SaveValidate
-    @PostMapping(value = "pvModuleModel/")
-    public ResponseVO savePvModuleModel(@RequestBody PvModuleModel pvModuleModel) {
-        try {
-            pvModuleModelService.save(pvModuleModel);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 保存光伏组件信息异常");
-            return ResponseVO.fail();
-        }
+  }
 
+  /**
+   * 保存光伏组件信息
+   *
+   * @param pvModuleModel 参数
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PostMapping(value = "pvModuleModel/")
+  public ResponseVO savePvModuleModel(@RequestBody PvModuleModel pvModuleModel) {
+    try {
+      pvModuleModelService.save(pvModuleModel);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 保存光伏组件信息异常");
+      return ResponseVO.fail();
     }
 
-    /**
-     * 更新光伏组件信息
-     *
-     * @param pvModuleModel 参数
-     * @return 执行结果
-     */
-    @SaveValidate
-    @PutMapping(value = "pvModuleModel/")
-    public ResponseVO updatePvModuleModel(@RequestBody PvModuleModel pvModuleModel) {
-        try {
-            pvModuleModelService.save(pvModuleModel);
-            return ResponseVO.success();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 更新光伏组件信息异常");
-            return ResponseVO.fail();
-        }
+  }
 
+  /**
+   * 更新光伏组件信息
+   *
+   * @param pvModuleModel 参数
+   * @return 执行结果
+   */
+  @SaveValidate
+  @PutMapping(value = "pvModuleModel/")
+  public ResponseVO updatePvModuleModel(@RequestBody PvModuleModel pvModuleModel) {
+    try {
+      pvModuleModelService.save(pvModuleModel);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 更新光伏组件信息异常");
+      return ResponseVO.fail();
     }
 
-    /**
-     * 删除光伏组件信息
-     *
-     * @param ids 删除id
-     * @return 执行结果
-     */
-    @SaveValidate
-    @DeleteMapping(value="pvModuleModel/{ids}")
-    public ResponseVO deletePvModuleModel(@PathVariable("ids")String ids){
-        try{
-            pvModuleModelService.delete(ids);
-            return ResponseVO.success();
-        }catch(Exception e){
-            e.printStackTrace();
-            log.error(" 删除光伏组件信息异常");
-            return ResponseVO.fail();
-        }
+  }
 
+  /**
+   * 删除光伏组件信息
+   *
+   * @param ids 删除id
+   * @return 执行结果
+   */
+  @SaveValidate
+  @DeleteMapping(value = "pvModuleModel/{ids}")
+  public ResponseVO deletePvModuleModel(@PathVariable("ids") String ids) {
+    try {
+      pvModuleModelService.delete(ids);
+      return ResponseVO.success();
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 删除光伏组件信息异常");
+      return ResponseVO.fail();
     }
 
+  }
+
   /**
    * 获取光伏组件旋转方式枚举
    *
    * @return 执行结果
    */
-    @GetMapping(value = "getPvRotationMode/")
-    public ResponseVO getPvRotationMode() {
-        List<Map<String, Object>> provinceType = new ArrayList<>();
-        Map<String, Object> map;
-        try {
-            for (PvRotationModeEnum e : PvRotationModeEnum.values()) {
-                map = new HashMap<>();
-                map.put("label", e.getMessage());
-                map.put("key", e.name());
-                map.put("value", e.name());
-                provinceType.add(map);
-            }
-            return ResponseVO.success(provinceType);
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(" 获取光伏组件旋转类型异常");
-            return ResponseVO.fail(provinceType);
-        }
-
+  @GetMapping(value = "getPvRotationMode/")
+  public ResponseVO getPvRotationMode() {
+    List<Map<String, Object>> provinceType = new ArrayList<>();
+    Map<String, Object> map;
+    try {
+      for (PvRotationModeEnum e : PvRotationModeEnum.values()) {
+        map = new HashMap<>();
+        map.put("label", e.getMessage());
+        map.put("key", e.name());
+        map.put("value", e.name());
+        provinceType.add(map);
+      }
+      return ResponseVO.success(provinceType);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error(" 获取光伏组件旋转类型异常");
+      return ResponseVO.fail(provinceType);
     }
 
+  }
+
 
 }

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

@@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.sql.SQLException;
 import java.util.Map;
 
 /**
@@ -117,7 +116,7 @@ public class QuartzController {
 
   @SneakyThrows
   @GetMapping(value = "initJobClasses/initJob")
-  public ResponseVO initJobClass() throws SQLException {
+  public ResponseVO initJobClass() {
     Boolean b = quartzService.initJobClass();
     if (!b) {
       return ResponseVO.fail("初始化失败,请检查sql文件是否存在");

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

@@ -24,89 +24,89 @@ import java.util.List;
 @Slf4j
 public class SysParameterController {
 
-    private final SysParameterService sysParameterService;
+  private final SysParameterService sysParameterService;
 
-    @Autowired
-    public SysParameterController(SysParameterService sysParameterService) {
-      this.sysParameterService = sysParameterService;
-    }
-
-    /**
-     * 新增系统参数
-     *
-     * @param sysParameter 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @PostMapping()
-    @SaveValidate
-    public ResponseVO add(@RequestBody SysParameter sysParameter) {
-      try {
-        this.sysParameterService.add(sysParameter);
-        return ResponseVO.success(1);
-      } catch (Exception ex) {
-        log.error("系统错误" + ex);
-        return ResponseVO.error(ex);
-      }
-
-    }
+  @Autowired
+  public SysParameterController(SysParameterService sysParameterService) {
+    this.sysParameterService = sysParameterService;
+  }
 
-    /**
-     * 修改系统参数
-     *
-     * @param sysParameter 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @PutMapping()
-    public ResponseVO update(@RequestBody SysParameter sysParameter) {
-      this.sysParameterService.update(sysParameter);
+  /**
+   * 新增系统参数
+   *
+   * @param sysParameter 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @PostMapping()
+  @SaveValidate
+  public ResponseVO add(@RequestBody SysParameter sysParameter) {
+    try {
+      this.sysParameterService.add(sysParameter);
       return ResponseVO.success(1);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 删除系统参数
-     *
-     * @param sysParameter 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @DeleteMapping()
-    public ResponseVO delete(@RequestBody SysParameter sysParameter) {
-      this.sysParameterService.delete(sysParameter.getId());
-      return ResponseVO.success(1);
-    }
+  }
 
+  /**
+   * 修改系统参数
+   *
+   * @param sysParameter 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PutMapping()
+  public ResponseVO update(@RequestBody SysParameter sysParameter) {
+    this.sysParameterService.update(sysParameter);
+    return ResponseVO.success(1);
+  }
 
-    /**
-     * 获取该场站下的所有参数
-     *
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping(value = "/{stationCode}")
-    public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
-      List<SysParameter> list = this.sysParameterService.getAllByStationCode(stationCode);
-      return ResponseVO.success(list);
-    }
+  /**
+   * 删除系统参数
+   *
+   * @param sysParameter 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @DeleteMapping()
+  public ResponseVO delete(@RequestBody SysParameter sysParameter) {
+    this.sysParameterService.delete(sysParameter.getId());
+    return ResponseVO.success(1);
+  }
 
 
-    /**
-     * 获取系统参数
-     *
-     * @param page
-     * @param size
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping(value = "/{page}/{size}")
-    public ResponseVO getAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
-      SysParameter sysParameter = new SysParameter();
-      Page<SysParameter> sysParameterPage = this.sysParameterService.get(sysParameter, page, size);
-      return ResponseVO.success(sysParameterPage);
-    }
+  /**
+   * 获取该场站下的所有参数
+   *
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{stationCode}")
+  public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
+    List<SysParameter> list = this.sysParameterService.getAllByStationCode(stationCode);
+    return ResponseVO.success(list);
+  }
+
+
+  /**
+   * 获取系统参数
+   *
+   * @param page
+   * @param size
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{page}/{size}")
+  public ResponseVO getAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
+    SysParameter sysParameter = new SysParameter();
+    Page<SysParameter> sysParameterPage = this.sysParameterService.get(sysParameter, page, size);
+    return ResponseVO.success(sysParameterPage);
+  }
 
 
   /**
@@ -118,22 +118,22 @@ public class SysParameterController {
    */
   @SneakyThrows
   @GetMapping(value = "/{page}/{size}/{keywords}")
-  public ResponseVO getAForKeywords(@PathVariable("page") Integer page, @PathVariable("size") Integer size,@PathVariable("keywords") String keywords) {
+  public ResponseVO getAForKeywords(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("keywords") String keywords) {
     SysParameter sysParameter = new SysParameter();
-    Page<SysParameter> sysParameterPage = this.sysParameterService.getForKeywords(sysParameter, page, size,keywords);
+    Page<SysParameter> sysParameterPage = this.sysParameterService.getForKeywords(sysParameter, page, size, keywords);
     return ResponseVO.success(sysParameterPage);
   }
 
-    /**
-     * 根据参数标识获取系统参数
-     *
-     * @param id
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping(value = "/sysParameter/{id}/")
-    public ResponseVO getById(@PathVariable("sysKey") Integer id) {
-      return ResponseVO.success(sysParameterService.getParameter(id));
-    }
+  /**
+   * 根据参数标识获取系统参数
+   *
+   * @param sysKey
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/sysParameter/{sysKey}/")
+  public ResponseVO getById(@PathVariable("sysKey") Integer sysKey) {
+    return ResponseVO.success(sysParameterService.getParameter(sysKey));
+  }
 
 }

+ 89 - 89
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WeatherStationInfoController.java

@@ -7,7 +7,6 @@ import com.jiayue.ipfcst.console.service.WeatherStationInfoService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -24,110 +23,111 @@ import java.util.List;
 @Slf4j
 public class WeatherStationInfoController {
 
-    private final WeatherStationInfoService weatherStationInfoService;
+  private final WeatherStationInfoService weatherStationInfoService;
 
-    @Autowired
-    public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService) {
-        this.weatherStationInfoService = weatherStationInfoService;
+  @Autowired
+  public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService) {
+    this.weatherStationInfoService = weatherStationInfoService;
+  }
+
+  /**
+   * 新增环境监测仪
+   *
+   * @param weatherStationInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PostMapping()
+  public ResponseVO add(@RequestBody WeatherStationInfo weatherStationInfo) {
+    try {
+      this.weatherStationInfoService.add(weatherStationInfo);
+      return ResponseVO.success(1);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 新增环境监测仪
-     *
-     * @param weatherStationInfo 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @PostMapping()
-    public ResponseVO add(@RequestBody WeatherStationInfo weatherStationInfo) {
-      try {
-        this.weatherStationInfoService.add(weatherStationInfo);
-        return ResponseVO.success(1);
-      } catch (Exception ex) {
-        log.error("系统错误" + ex);
-        return ResponseVO.error(ex);
-      }
 
+  }
 
+  /**
+   * 修改环境监测仪
+   *
+   * @param weatherStationInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PutMapping()
+  public ResponseVO update(@RequestBody WeatherStationInfo weatherStationInfo) {
+    try {
+      this.weatherStationInfoService.update(weatherStationInfo);
+      return ResponseVO.success(1);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 修改环境监测仪
-     *
-     * @param weatherStationInfo 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @PutMapping()
-    public ResponseVO update(@RequestBody WeatherStationInfo weatherStationInfo) {
-      try {
-        this.weatherStationInfoService.update(weatherStationInfo);
-        return ResponseVO.success(1);
-      } catch (Exception ex) {
-        log.error("系统错误" + ex);
-        return ResponseVO.error(ex);
-      }
+  }
 
+  /**
+   * 获取环境监测仪
+   *
+   * @param weatherStationInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping("/ById")
+  public ResponseVO get(@RequestBody WeatherStationInfo weatherStationInfo) {
+    try {
+      weatherStationInfo = this.weatherStationInfoService.get(weatherStationInfo.getId());
+      return ResponseVO.success(weatherStationInfo);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 获取环境监测仪
-     *
-     * @param weatherStationInfo 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping("/ById")
-    public ResponseVO get(@RequestBody WeatherStationInfo weatherStationInfo) {
-        try {
-          weatherStationInfo = this.weatherStationInfoService.get(weatherStationInfo.getId());
-          return ResponseVO.success(weatherStationInfo);
-        } catch (Exception ex) {
-          log.error("系统错误" + ex);
-          return ResponseVO.error(ex);
-        }
+  }
 
+  /**
+   * 删除环境监测仪
+   *
+   * @param id 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @DeleteMapping("/{id}")
+  public ResponseVO delete(@PathVariable Integer id) {
+    try {
+      this.weatherStationInfoService.delete(id);
+      return ResponseVO.success(1);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 删除环境监测仪
-     *
-     * @param id 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @DeleteMapping("/{id}")
-    public ResponseVO delete(@PathVariable Integer id) {
-      try {
-        this.weatherStationInfoService.delete(id);
-        return ResponseVO.success(1);
-      } catch (Exception ex) {
-        log.error("系统错误" + ex);
-        return ResponseVO.error(ex);
-      }
+  }
 
+  /**
+   * RequestParams
+   * 获取环境监测仪
+   *
+   * @param stationCode 参数
+   * @return 执行结果
+   */
+  @GetMapping(value = "/{stationCode}")
+  public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
+    try {
+      List<WeatherStationInfo> weatherStationInfoPage = this.weatherStationInfoService.get(stationCode);
+      return ResponseVO.success(weatherStationInfoPage);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**RequestParams
-     * 获取环境监测仪
-     *
-     * @param stationCode 参数
-     * @return 执行结果
-     */
-    @GetMapping(value = "/{stationCode}")
-    public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
-        try {
-          List<WeatherStationInfo> weatherStationInfoPage = this.weatherStationInfoService.get(stationCode);
-          return ResponseVO.success(weatherStationInfoPage);
-        } catch (Exception ex) {
-          log.error("系统错误" + ex);
-          return ResponseVO.error(ex);
-        }
-
-    }
+  }
 
   /**
    * 获取环境监测仪

+ 9 - 9
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WeatherStationStatusDataController.java

@@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
+
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -25,21 +25,21 @@ public class WeatherStationStatusDataController {
   private final WeatherStationStatusDataService weatherStationStatusDataService;
 
   @Autowired
-  public WeatherStationStatusDataController(WeatherStationStatusDataService weatherStationStatusDataService){
-    this.weatherStationStatusDataService=weatherStationStatusDataService;
+  public WeatherStationStatusDataController(WeatherStationStatusDataService weatherStationStatusDataService) {
+    this.weatherStationStatusDataService = weatherStationStatusDataService;
   }
 
   @GetMapping(value = "/weatherStationStatusData/{stationCode}/{startTime}/{endTime}/{page}/{size}/{no}")
-  public ResponseVO findByTimeBetweenAndNoAndTimeStep(@PathVariable("stationCode") String stationCode,@PathVariable("startTime") Long startTime,
+  public ResponseVO findByTimeBetweenAndNoAndTimeStep(@PathVariable("stationCode") String stationCode, @PathVariable("startTime") Long startTime,
                                                       @PathVariable("endTime") Long endTime,
                                                       @PathVariable("page") Integer page,
                                                       @PathVariable("size") Integer size,
-                                                      @PathVariable("no") String no){
-    Map<String,Object> map = new HashMap<>();
-    try{
-      map =  weatherStationStatusDataService.findByTimeBetweenAndNoAndTimeStep(stationCode,new Date(startTime),new Date(endTime),page,size,no);
+                                                      @PathVariable("no") String no) {
+    Map<String, Object> map;
+    try {
+      map = weatherStationStatusDataService.findByTimeBetweenAndNoAndTimeStep(stationCode, new Date(startTime), new Date(endTime), page, size, no);
       return ResponseVO.success(map);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("气象数据分页查询错误");
       return ResponseVO.fail(e.toString());

+ 74 - 71
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTowerInfoController.java

@@ -2,13 +2,11 @@ package com.jiayue.ipfcst.console.controller;
 
 import com.jiayue.ipfcst.aop.SaveValidate;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
-import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTowerInfo;
 import com.jiayue.ipfcst.console.service.WindTowerInfoService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -22,82 +20,87 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("windTowerInfo")
-@Slf4j public class WindTowerInfoController {
+@Slf4j
+public class WindTowerInfoController {
 
-    private final WindTowerInfoService windTowerInfoService;
+  private final WindTowerInfoService windTowerInfoService;
 
-    @Autowired public WindTowerInfoController(WindTowerInfoService windTowerInfoService) {
-        this.windTowerInfoService = windTowerInfoService;
-    }
-
-    /**
-     * 新增测风塔
-     *
-     * @param windTowerInfo 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @PostMapping() public ResponseVO add(@RequestBody WindTowerInfo windTowerInfo) {
-        try {
-            this.windTowerInfoService.add(windTowerInfo);
-            return ResponseVO.success(1);
-        } catch (Exception ex) {
-            log.error("系统错误" + ex);
-            return ResponseVO.error(ex);
-        }
+  @Autowired
+  public WindTowerInfoController(WindTowerInfoService windTowerInfoService) {
+    this.windTowerInfoService = windTowerInfoService;
+  }
 
+  /**
+   * 新增测风塔
+   *
+   * @param windTowerInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PostMapping()
+  public ResponseVO add(@RequestBody WindTowerInfo windTowerInfo) {
+    try {
+      this.windTowerInfoService.add(windTowerInfo);
+      return ResponseVO.success(1);
+    } catch (Exception ex) {
+      log.error("系统错误" + ex);
+      return ResponseVO.error(ex);
     }
 
-    /**
-     * 修改测风塔
-     *
-     * @param windTowerInfo 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @PutMapping() public ResponseVO update(@RequestBody WindTowerInfo windTowerInfo) {
-        this.windTowerInfoService.update(windTowerInfo);
-        return ResponseVO.success(1);
-    }
+  }
 
-    /**
-     * 删除测风塔
-     *
-     * @param id 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @SaveValidate
-    @DeleteMapping("/{id}") public ResponseVO delete(@PathVariable Integer id) {
-        this.windTowerInfoService.delete(id);
-        return ResponseVO.success(1);
-    }
+  /**
+   * 修改测风塔
+   *
+   * @param windTowerInfo 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @PutMapping()
+  public ResponseVO update(@RequestBody WindTowerInfo windTowerInfo) {
+    this.windTowerInfoService.update(windTowerInfo);
+    return ResponseVO.success(1);
+  }
 
-    /**
-     * 获取测风塔
-     *
-     * @param stationCode 参数
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping(value = "/{stationCode}")
-    public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
-      List<WindTowerInfo> windTowerPage = this.windTowerInfoService.get(stationCode);
-        return ResponseVO.success(windTowerPage);
-    }
+  /**
+   * 删除测风塔
+   *
+   * @param id 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @SaveValidate
+  @DeleteMapping("/{id}")
+  public ResponseVO delete(@PathVariable Integer id) {
+    this.windTowerInfoService.delete(id);
+    return ResponseVO.success(1);
+  }
 
-    /**
-     * 获取测风塔
-     *
-     * @return 执行结果
-     */
-    @SneakyThrows
-    @GetMapping(value = "")
-    public ResponseVO getAll() {
+  /**
+   * 获取测风塔
+   *
+   * @param stationCode 参数
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "/{stationCode}")
+  public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
+    List<WindTowerInfo> windTowerPage = this.windTowerInfoService.get(stationCode);
+    return ResponseVO.success(windTowerPage);
+  }
 
-      List<WindTowerInfo> list = this.windTowerInfoService.getAll();
-      return ResponseVO.success(list);
-    }
+  /**
+   * 获取测风塔
+   *
+   * @return 执行结果
+   */
+  @SneakyThrows
+  @GetMapping(value = "")
+  public ResponseVO getAll() {
+
+    List<WindTowerInfo> list = this.windTowerInfoService.getAll();
+    return ResponseVO.success(list);
+  }
 }

+ 8 - 15
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTowerStatusDataController.java

@@ -8,14 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -32,8 +25,8 @@ public class WindTowerStatusDataController {
   private final WindTowerStatusDataService windTowerStatusDataService;
 
   @Autowired
-  public WindTowerStatusDataController(WindTowerStatusDataService windTowerStatusDataService){
-    this.windTowerStatusDataService=windTowerStatusDataService;
+  public WindTowerStatusDataController(WindTowerStatusDataService windTowerStatusDataService) {
+    this.windTowerStatusDataService = windTowerStatusDataService;
   }
 
 //  /**
@@ -64,16 +57,16 @@ public class WindTowerStatusDataController {
 //  }
 
   @GetMapping(value = "/windTowerStatusData/{stationCode}/{startTime}/{endTime}/{page}/{size}/{no}")
-  public ResponseVO findByTimeBetweenAndNoAndTimeStep(@PathVariable("stationCode") String stationCode,@PathVariable("startTime") Long startTime,
+  public ResponseVO findByTimeBetweenAndNoAndTimeStep(@PathVariable("stationCode") String stationCode, @PathVariable("startTime") Long startTime,
                                                       @PathVariable("endTime") Long endTime,
                                                       @PathVariable("page") Integer page,
                                                       @PathVariable("size") Integer size,
-                                                      @PathVariable("no") String no){
-    Map<String,Object> map = new HashMap<>();
-    try{
-      map =  windTowerStatusDataService.findByTimeBetweenAndNoAndTimeStep(stationCode,new Date(startTime),new Date(endTime),page,size,no);
+                                                      @PathVariable("no") String no) {
+    Map<String, Object> map;
+    try {
+      map = windTowerStatusDataService.findByTimeBetweenAndNoAndTimeStep(stationCode, new Date(startTime), new Date(endTime), page, size, no);
       return ResponseVO.success(map);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("测风数据分页查询错误");
       return ResponseVO.fail(e.toString());

+ 5 - 7
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTurbineInfoController.java

@@ -3,8 +3,6 @@ package com.jiayue.ipfcst.console.controller;
 import com.jiayue.ipfcst.aop.SaveValidate;
 import com.jiayue.ipfcst.common.core.web.vo.RequestVO;
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
-import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipfcst.console.service.WindTurbineInfoService;
 import lombok.SneakyThrows;
@@ -13,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -161,15 +158,16 @@ public class WindTurbineInfoController {
 
   /**
    * 查询所有逆变器设备信息按ID排序 yh
+   *
    * @return 结果集
    */
   @GetMapping(value = "findWindTurbineInfoByStation/{stationCode}")
-  public ResponseVO findWindTurbineInfoByStation(@PathVariable("stationCode") String stationCode){
-    List<WindTurbineInfo> list = new ArrayList<>();
-    try{
+  public ResponseVO findWindTurbineInfoByStation(@PathVariable("stationCode") String stationCode) {
+    List<WindTurbineInfo> list;
+    try {
       list = windTurbineInfoService.getByStationCode(stationCode);
       return ResponseVO.success(list);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("风机信息所有查询错误");
       return ResponseVO.fail(e.toString());

+ 23 - 23
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/WindTurbineStatusDataController.java

@@ -1,16 +1,15 @@
 package com.jiayue.ipfcst.console.controller;
 
 import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
-import com.jiayue.ipfcst.console.service.WindTurbineInfoService;
 import com.jiayue.ipfcst.console.service.WindTurbineStatusDataService;
 import lombok.extern.slf4j.Slf4j;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.*;
+import java.util.Date;
+import java.util.Map;
 
 
 @RestController
@@ -18,21 +17,21 @@ import java.util.*;
 public class WindTurbineStatusDataController {
 
   private final WindTurbineStatusDataService windTurbineStatusDataService;
-  private final WindTurbineInfoService windTurbineInfoService;
+
   @Autowired
-  public WindTurbineStatusDataController(WindTurbineStatusDataService windTurbineStatusDataService, WindTurbineInfoService windTurbineInfoService){
+  public WindTurbineStatusDataController(WindTurbineStatusDataService windTurbineStatusDataService) {
     this.windTurbineStatusDataService = windTurbineStatusDataService;
-    this.windTurbineInfoService = windTurbineInfoService;
   }
 
 
   /**
    * 分页查询 所有风机功率状态
+   *
    * @param startTime 开始时间
-   * @param endTime 结束时间
-   * @param page 页码
-   * @param size 条数
-   * @param no   风机编号
+   * @param endTime   结束时间
+   * @param page      页码
+   * @param size      条数
+   * @param no        风机编号
    * @return
    */
   @GetMapping(value = "/windTurbineStatusData/{stationCode}/{startTime}/{endTime}/{page}/{size}/{no}")
@@ -41,12 +40,12 @@ public class WindTurbineStatusDataController {
                                                @PathVariable("endTime") Long endTime,
                                                @PathVariable("page") Integer page,
                                                @PathVariable("size") Integer size,
-                                               @PathVariable("no") String no){
-    Map<String,Object> map = new HashMap<>();
-    try{
-      map =  windTurbineStatusDataService.findByTimeBetweenForPaging(stationCode,new Date(startTime),new Date(endTime),page,size,no);
+                                               @PathVariable("no") String no) {
+    Map<String, Object> map;
+    try {
+      map = windTurbineStatusDataService.findByTimeBetweenForPaging(stationCode, new Date(startTime), new Date(endTime), page, size, no);
       return ResponseVO.success(map);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("风机分页查询错误");
       return ResponseVO.fail(e.toString());
@@ -55,10 +54,11 @@ public class WindTurbineStatusDataController {
 
   /**
    * 分页查询  按设备编号查询风机状态
+   *
    * @param startTime 开始时间
-   * @param endTime 结束时间
-   * @param page 页码
-   * @param size 条数
+   * @param endTime   结束时间
+   * @param page      页码
+   * @param size      条数
    * @return
    */
   @GetMapping(value = "/windTurbineStatusData/{startTime}/{endTime}/{page}/{size}/{no}")
@@ -67,12 +67,12 @@ public class WindTurbineStatusDataController {
                                                @PathVariable("page") Integer page,
                                                @PathVariable("size") Integer size,
                                                @PathVariable("no") Integer[] no,
-                                               String timeSortOrder, String noSortOrder){
-    Map<String,Object> map = new HashMap<>();
-    try{
-      map =  windTurbineStatusDataService.findByTimeBetweenAndNoForPaging(new Date(startTime),new Date(endTime),page,size,no,timeSortOrder,noSortOrder);
+                                               String timeSortOrder, String noSortOrder) {
+    Map<String, Object> map;
+    try {
+      map = windTurbineStatusDataService.findByTimeBetweenAndNoForPaging(new Date(startTime), new Date(endTime), page, size, no, timeSortOrder, noSortOrder);
       return ResponseVO.success(map);
-    }catch(Exception e){
+    } catch (Exception e) {
       e.printStackTrace();
       log.error("按设备号风机分页查询错误");
       return ResponseVO.fail(e.toString());

+ 0 - 44
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/dto/ResponseResults.java

@@ -1,44 +0,0 @@
-package com.jiayue.ipfcst.console.dto;
-
-/**
-   * 通用查询请求结果 DTO
- *
- * @author whc
- * @version 2.0
- * @since 2021/9/26
- */
-public class ResponseResults {
-  //设备id
-  private String deviceId;
-  //结果数组
-  private ResponseRows rows;
-  //测点ID
-  private String[] sensorIds;
-
-  public String getDeviceId() {
-    return deviceId;
-  }
-
-  public void setDeviceId(String deviceId) {
-    this.deviceId = deviceId;
-  }
-
-  public ResponseRows getRows() {
-    return rows;
-  }
-
-  public void setRows(ResponseRows rows) {
-    this.rows = rows;
-  }
-
-  public String[] getSensorIds() {
-    return sensorIds;
-  }
-
-  public void setSensorIds(String[] sensorIds) {
-    this.sensorIds = sensorIds;
-  }
-
-
-
-}

+ 0 - 30
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/dto/ResponseRows.java

@@ -1,30 +0,0 @@
-package com.jiayue.ipfcst.console.dto;
-/**
- * 通用查询请求结果数据行 DTO
- *
- * @author whc
- * @version 2.0
- * @since 2021/9/26
- */
-public class ResponseRows {
-  //数据时间戳
-  private Long timestamp;
-  //数据值
-  private String[] values;
-
-  public Long getTimestamp() {
-    return timestamp;
-  }
-
-  public void setTimestamp(Long timestamp) {
-    this.timestamp = timestamp;
-  }
-
-  public String[] getValues() {
-    return values;
-  }
-
-  public void setValues(String[] values) {
-    this.values = values;
-  }
-}

+ 8 - 10
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/job/FileAnalysisJob.java

@@ -1,7 +1,5 @@
 package com.jiayue.ipfcst.console.job;
 
-import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.console.service.FileAnalysisService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,19 +18,19 @@ import org.springframework.stereotype.Service;
 @EnableScheduling
 public class FileAnalysisJob {
 
-    @Autowired
-    private FileAnalysisService fileAnalysisService;
+  @Autowired
+  private FileAnalysisService fileAnalysisService;
 
-    @Scheduled(cron = "0 0/1 * * * *")
-    public void fxglFileAnalysis() {
+  @Scheduled(cron = "0 0/1 * * * *")
+  public void fxglFileAnalysis() {
 
-        log.debug("文件解析定时任务执行开始");
+    log.debug("文件解析定时任务执行开始");
 
-        this.fileAnalysisService.analysisJob();
+    this.fileAnalysisService.analysisJob();
 
-        log.debug("文件解析定时任务执行完成");
+    log.debug("文件解析定时任务执行完成");
 
-    }
+  }
 
 
 }

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

@@ -23,14 +23,14 @@ public class ReceiveDataJob {
   private ReceiveDataService receiveDataService;
 
 
-  @Scheduled(fixedDelay = 60000)
+  @Scheduled(cron = "0 0/1 * * * *")
   public void receiveData() {
 
-    log.debug("开始向绿能数据中心请求数据");
+    log.info("开始向绿能数据中心请求数据");
 
     this.receiveDataService.receive();
 
-    log.debug("数据请求结束");
+    log.info("数据请求结束");
 
   }
 

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

@@ -1,6 +1,7 @@
 package com.jiayue.ipfcst.console.service;
 
 
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.DataPoint;
 import com.jiayue.ipfcst.common.data.repository.DataPointRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
@@ -23,7 +24,7 @@ public class DataPointService extends BaseService {
    * 查询设备下所有测点
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public List<DataPoint> getByEquipmentType(Integer equipmentType) {
+  public List<DataPoint> getByEquipmentType(EquipmentTypeEnum equipmentType) {
     List<DataPoint> resultList;
     resultList = this.dataPointRepository.findAllByEquipmentType(equipmentType);
     return resultList;

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

@@ -37,8 +37,6 @@ public class DownLoadService {
       List<FileCreateLog> list = array.toList(FileCreateLog.class);
       Date date = new Date();
       SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
-      //String dir = FileUtil.getDownloadFilePath() +File.separator+stationCode+File.separator+"new/";
-      //String dirBak = FileUtil.getDownloadFilePath() +File.separator+stationCode+File.separator+"backups/"+simpleDateFormat.format(date)+"/";
       //测试使用
       String dir = "/Users/wanghongchen/fsdownload/" + stationCode + "/" + "new/";
       String dirBak = "/Users/wanghongchen/fsdownload/" + stationCode + "/" + "backups/" + simpleDateFormat.format(date) + "/";

+ 5 - 86
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerShortTermHisService.java

@@ -14,9 +14,10 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 历史预测短期业务层
@@ -35,45 +36,6 @@ public class ForecastPowerShortTermHisService extends BaseService {
   }
 
   /**
-   * 根据提前多久,开始结束时间查询历史超短期 yh
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   * @param ago       提前多久预测
-   * @return 结果集
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTime(Long startTime, Long endTime, Integer ago) {
-    Map<String, Object> map = new HashMap<>();
-    List<ForecastPowerShortTermHis> list = forecastPowerShortTermHisRepository.findByForecastTimeBetweenAndForecastHowLongAgo(startTime, endTime, ago);
-    list.sort(Comparator.comparing(ForecastPowerShortTermHis::getForecastTime));
-    long timeStep = 900000L;
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    List<String> times = new ArrayList<>();
-    List<Float> datas = new ArrayList<>();
-    if (startTime % timeStep != 0) {
-      startTime = startTime - (startTime % timeStep) + timeStep;
-    }
-    if (list != null && list.size() > 0) {
-      for (Long i = startTime; i < endTime; i = i + timeStep) {
-        long finalI = i;
-        List<ForecastPowerShortTermHis> filterList = list.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
-        if (filterList != null && filterList.size() > 0) {
-          datas.add(filterList.get(0).getAbleValue().floatValue());
-        } else {
-          datas.add(null);
-        }
-
-        times.add(sdf.format(new Date(finalI)));
-      }
-    }
-    map.put("times", times);
-    map.put("datas", datas);
-
-    return map;
-  }
-
-  /**
    * 根据时间,场站编码查询历史短期数据
    *
    * @param startTime   开始时间
@@ -92,56 +54,13 @@ public class ForecastPowerShortTermHisService extends BaseService {
     Specification<ForecastPowerShortTermHis> specification = this.specificationFindByTimeAndNo(startTime, endTime, stationCode);
     Pageable pageable = PageRequest.of(page - 1, size, sort);
     Page forecastPowerShortTermHiss = forecastPowerShortTermHisRepository.findAll(specification, pageable);
-    List<ForecastPowerShortTermHis> datas = forecastPowerShortTermHiss.getContent();
+    List datas = forecastPowerShortTermHiss.getContent();
     map.put("content", datas);
     map.put("count", forecastPowerShortTermHiss.getTotalElements());
 
     return map;
   }
 
-
-  /**
-   * 根据提前多久,开始结束时间查询历史超短期 yh
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   * @param ago       提前多久预测
-   * @return 结果集
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTimeForDB(Long startTime, Long endTime, Integer ago, Long timeStep) {
-    Map<String, Object> map = new HashMap<>();
-    List<ForecastPowerShortTermHis> list = forecastPowerShortTermHisRepository.findByForecastTimeBetweenAndForecastHowLongAgo(startTime, endTime, ago);
-    list.sort(Comparator.comparing(ForecastPowerShortTermHis::getForecastTime));
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    List<String> times = new ArrayList<>();
-    List<Float> datas = new ArrayList<>();
-    if (startTime % timeStep != 0) {
-      startTime = startTime - (startTime % timeStep) + timeStep;
-    }
-    for (Long i = startTime; i < endTime; i = i + timeStep) {
-      if (list != null && list.size() > 0) {
-        long finalI = i;
-        List<ForecastPowerShortTermHis> filterList = list.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
-        if (filterList != null && filterList.size() > 0) {
-          datas.add(filterList.get(0).getAbleValue().floatValue());
-        } else {
-          datas.add(null);
-        }
-      } else {
-        datas.add(null);
-      }
-      times.add(sdf.format(new Date(i)));
-
-    }
-
-    map.put("times", times);
-    map.put("datas", datas);
-
-    return map;
-  }
-
-
   /**
    * 根据时间和编号 分页查询条件 yh
    *

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

@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -86,7 +87,7 @@ public class ForecastPowerShortTermService extends BaseService {
     log.info(stationCode + "查询现有短期预测记录数:" + forecastPowerShortTerms.size());
     // 判断查询结果是否满足查询所需
     Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
-    Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
+    int moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
     log.info(stationCode + "获取所需记录数:" + moments);
     if (moments > forecastPowerShortTerms.size()) {
       Map<Long, List<ForecastPowerShortTerm>> forecastPowerShortTermsMap =
@@ -97,7 +98,7 @@ public class ForecastPowerShortTermService extends BaseService {
         if (forecastPowerShortTermsMap.get(tempTime) == null) {
           // 缺失时间点
           ForecastPowerShortTerm _forecastPowerShortTerms = this.generateForecastPowerShortTerm(tempTime,
-            electricFieldInfo, openCapacityMap.get(tempTime));
+            electricFieldInfo, openCapacityMap != null ? openCapacityMap.get(tempTime) : electricFieldInfo.getCapacity());
           addForecastPowerShortTermList.add(_forecastPowerShortTerms);
         }
       }
@@ -126,13 +127,13 @@ public class ForecastPowerShortTermService extends BaseService {
       forecastPowerShortTermHis.setCapacity(electricFieldInfo.getCapacity());
       // 预测可用功率=预测*(开机容量/装机容量)
       BigDecimal ableValue =
-        _forecastPowerShortTerm.getFpValue().multiply(openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()))
-          .divide(electricFieldInfo.getCapacity(), 2, BigDecimal.ROUND_HALF_UP);
+        _forecastPowerShortTerm.getFpValue().multiply(openCapacityMap != null ? openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()) : electricFieldInfo.getCapacity())
+          .divide(electricFieldInfo.getCapacity(), 2, RoundingMode.HALF_UP);
 
       forecastPowerShortTermHis.setAbleValue(ableValue.compareTo(lpl) == -1 ? lpl : ableValue);
       forecastPowerShortTermHis.setPredictionModelEnum(_forecastPowerShortTerm.getPredictionModelEnum());
       forecastPowerShortTermHis.setGenDate(new Date());
-      forecastPowerShortTermHis.setSuCapacity(openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()));
+      forecastPowerShortTermHis.setSuCapacity(openCapacityMap != null ? openCapacityMap.get(_forecastPowerShortTerm.getForecastTime()) : electricFieldInfo.getCapacity());
       // 设置提前几天预测
       forecastPowerShortTermHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime,
         forecastPowerShortTermHis.getForecastTime()));
@@ -186,7 +187,7 @@ public class ForecastPowerShortTermService extends BaseService {
     ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
     forecastPowerShortTerm.setForecastTime(tempTime);
     BigDecimal tempValue;
-    BigDecimal randomValue = new BigDecimal(CommonUtil.getRandom(97, 99) / 100.0);
+    BigDecimal randomValue = BigDecimal.valueOf(CommonUtil.getRandom(97, 99) / 100.0);
     if (DateTimeUtil.checkInSunriseAndSunset(tempTime, electricFieldInfo.getLongitude().doubleValue(),
       electricFieldInfo.getLatitude().doubleValue())) {
       // 2021-4-22 xsl修改补数取固定系数
@@ -197,7 +198,7 @@ public class ForecastPowerShortTermService extends BaseService {
       tempValue = BigDecimal.ZERO;
     }
 
-    forecastPowerShortTerm.setFpValue(NumberUtils.multiply(tempValue, openCapacity).multiply(randomValue).setScale(2, BigDecimal.ROUND_HALF_UP));
+    forecastPowerShortTerm.setFpValue(NumberUtils.multiply(tempValue, openCapacity).multiply(randomValue).setScale(2, RoundingMode.HALF_UP));
     forecastPowerShortTerm.setGenDate(new Date());
     forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
     forecastPowerShortTerm.setStationCode(electricFieldInfo.getStationCode());
@@ -216,10 +217,10 @@ public class ForecastPowerShortTermService extends BaseService {
     System.out.println("风补数");
     ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
     forecastPowerShortTerm.setForecastTime(tempTime);
-    BigDecimal randomValue = new BigDecimal(CommonUtil.getRandom(97, 99) / 100.0d);
+    BigDecimal randomValue = BigDecimal.valueOf(CommonUtil.getRandom(97, 99) / 100.0d);
     // 2021-4-22 xsl修改补数取固定系数
     BigDecimal tempValue = new BigDecimal(Constant.forecastCoe(tempTime, ElectricFieldTypeEnum.E2));
-    forecastPowerShortTerm.setFpValue(NumberUtils.multiply(tempValue, openCapacity).multiply(randomValue).setScale(2, BigDecimal.ROUND_HALF_UP));
+    forecastPowerShortTerm.setFpValue(NumberUtils.multiply(tempValue, openCapacity).multiply(randomValue).setScale(2, RoundingMode.HALF_UP));
     forecastPowerShortTerm.setGenDate(new Date());
     forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
     forecastPowerShortTerm.setStationCode(stationCode);

+ 29 - 42
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java

@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -52,17 +53,6 @@ public class ForecastPowerUltraShortTermService extends BaseService {
   ForecastPowerShortTermService forecastPowerShortTermService;
 
   /**
-   * 生成超短期预测功率,自动更新覆盖预测功率
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  public void buildForecastPowerUltraShortTerm(@NotNull final Long startTime, @NotNull final Long endTime, String stationCode) {
-    this.getForecastPowerUltraShortTerm(startTime, endTime, stationCode);
-  }
-
-  /**
    * 获取超短期预测功率,当数据库中超短期预测记录不足查询所需时,进行本地化计算,用于上报专用
    *
    * @param startTime 开始时间
@@ -82,7 +72,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     } catch (BusinessException e) {
       log.error(stationCode + "超短期数据生成获取开机容量出错:" + CommonUtil.printStackTraceToString(e));
     }
-    Long monentTime = 0L;
+    long monentTime = 0L;
     try {
       monentTime = DateMomentUtil.getMomentTime(new Date().getTime(), 1, 15 * 60 * 1000L);
     } catch (Exception e) {
@@ -98,7 +88,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     }
 
     Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
-    Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
+    int moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
     log.info(stationCode + "所需时间moments个数:" + moments);
     log.info(stationCode + "获取所需记录数:" + forecastPowerUltraShortTermList.size());
     if (moments > forecastPowerUltraShortTermList.size()) {
@@ -109,22 +99,22 @@ public class ForecastPowerUltraShortTermService extends BaseService {
           BigDecimal tempValue;
           if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
             if (DateTimeUtil.checkInSunriseAndSunset(startTime, electricFieldInfo.getLongitude().doubleValue(), electricFieldInfo.getLatitude().doubleValue())) {
-              tempValue = new BigDecimal(CommonUtil.getRandom(1, 70) / 100.0d);
+              tempValue = BigDecimal.valueOf(CommonUtil.getRandom(1, 70) / 100.0d);
             } else {
               // 日升日落
               tempValue = BigDecimal.ZERO;
             }
           } else {
-            tempValue = new BigDecimal(CommonUtil.getRandom(1, 70) / 100.0d);
+            tempValue = BigDecimal.valueOf(CommonUtil.getRandom(1, 70) / 100.0d);
           }
-          tempValue = tempValue.multiply(electricFieldInfo.getCapacity()).setScale(2, BigDecimal.ROUND_HALF_UP);
+          tempValue = tempValue.multiply(electricFieldInfo.getCapacity()).setScale(2, RoundingMode.HALF_UP);
           ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
           forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
           forecastPowerUltraShortTerm.setForecastTime(tempTime);
           forecastPowerUltraShortTerm.setFpValue(tempValue);
           forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
-          forecastPowerUltraShortTerm.setCoefficientValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
-          forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
+          forecastPowerUltraShortTerm.setCoefficientValue(BigDecimal.valueOf(-0.99).setScale(2, RoundingMode.HALF_UP));
+          forecastPowerUltraShortTerm.setDifferenceValue(BigDecimal.valueOf(-0.99).setScale(2, RoundingMode.HALF_UP));
           forecastPowerUltraShortTerm.setStationCode(stationCode);
           // 保存超短期实时预测记录
           this.forecastPowerUltraShortTermRepository.save(forecastPowerUltraShortTerm);
@@ -145,7 +135,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     //生成数据
     for (ForecastPowerUltraShortTerm forecastPowerUltraShortTerm : forecastPowerUltraShortTermList) {
       forecastPowerUltraShortTermHis = new ForecastPowerUltraShortTermHis();
-      openCapacity = openCapacityMap.get(forecastPowerUltraShortTerm.getForecastTime());
+      openCapacity = openCapacityMap != null ? openCapacityMap.get(forecastPowerUltraShortTerm.getForecastTime()) : electricFieldInfo.getCapacity();
       forecastPowerUltraShortTermHis.setForecastTime(forecastPowerUltraShortTerm.getForecastTime());
       forecastPowerUltraShortTermHis.setSuCapacity(openCapacity);
       forecastPowerUltraShortTermHis.setCapacity(electricFieldInfo.getCapacity());
@@ -153,7 +143,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       forecastPowerUltraShortTermHis.setTheoryValue(forecastPowerUltraShortTerm.getFpValue());
       // 预测可用功率=预测*(开机容量/装机容量)
       BigDecimal fpValue = forecastPowerUltraShortTerm.getFpValue().multiply(openCapacity)
-        .divide(electricFieldInfo.getCapacity(), 2, BigDecimal.ROUND_HALF_UP);
+        .divide(electricFieldInfo.getCapacity(), 2, RoundingMode.HALF_UP);
       forecastPowerUltraShortTermHis.setAbleValue(fpValue);
       forecastPowerUltraShortTermHis.setPredictionModelEnum(forecastPowerUltraShortTerm.getPredictionModelEnum());
       forecastPowerUltraShortTermHis.setDifferenceValue(forecastPowerUltraShortTerm.getDifferenceValue());
@@ -164,11 +154,11 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     }
 //    List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHiss = forecastPowerUltraShortTermHiss1.stream().filter(t -> t.getForecastHowLongAgo() <=16).collect(Collectors.toList());
     // 获取实际功率替换超短期点位参数
-    Integer replacePoint = 0;
+    int replacePoint;
     String realpower_replace_cdq = sysParameterService.getSysParameter("realpower_replace_cdq", "0", stationCode);
-    replacePoint = Integer.valueOf(realpower_replace_cdq);
+    replacePoint = Integer.parseInt(realpower_replace_cdq);
     if (replacePoint <= forecastPowerUltraShortTermHiss.size() && replacePoint > 0) {
-      Long pre5Time = 0l;
+      long pre5Time;
       Date systemDate = new Date();
       try {
         // 获取前5分钟时刻
@@ -228,10 +218,10 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         // 根据场站类型执行相应超短期预测
         try {
           String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0", stationCode);
-          Long currentTime = System.currentTimeMillis() + Integer.parseInt(cdqUpMin) * 1000 * 60;
+          Long currentTime = System.currentTimeMillis() + (long) Integer.parseInt(cdqUpMin) * 1000 * 60;
           String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
-          Integer forecastPoints = Integer.parseInt(llcdq_point);
-          Integer forecastMinutes = forecastPoints * 15;
+          int forecastPoints = Integer.parseInt(llcdq_point);
+          int forecastMinutes = forecastPoints * 15;
 
           // 超短期提前N分钟生成文件
           Long startTime = DateMomentUtil.getMomentTime(currentTime, 1, 15 * 60 * 1000L);
@@ -252,11 +242,11 @@ public class ForecastPowerUltraShortTermService extends BaseService {
           for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + 15 * 60 * 1000L) {
             if (forecastPowerShortTermsMap.get(tempTime) == null) {
               // 缺失时间点
-              ForecastPowerShortTerm forecastPowerShortTerms = null;
+              ForecastPowerShortTerm forecastPowerShortTerms;
               if (ElectricFieldTypeEnum.E1.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
-                forecastPowerShortTerms = forecastPowerShortTermService.generateSolarPowerShortTerm(tempTime, openCapacityMap.get(tempTime), electricField);
+                forecastPowerShortTerms = forecastPowerShortTermService.generateSolarPowerShortTerm(tempTime, openCapacityMap != null ? openCapacityMap.get(tempTime) : electricField.getCapacity(), electricField);
               } else {
-                forecastPowerShortTerms = forecastPowerShortTermService.generateWindPowerShortTerm(tempTime, openCapacityMap.get(tempTime), stationCode);
+                forecastPowerShortTerms = forecastPowerShortTermService.generateWindPowerShortTerm(tempTime, openCapacityMap != null ? openCapacityMap.get(tempTime) : electricField.getCapacity(), stationCode);
               }
               addForecastPowerShortTermList.add(forecastPowerShortTerms);
             }
@@ -293,7 +283,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
    * @param forecastPowerShortTermList 短期预测结果集
    * @param capacity                   装机容量
    */
-  private List<ForecastPowerUltraShortTerm> executeForecastForWind(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity, String stationCode) {
+  private void executeForecastForWind(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity, String stationCode) {
     List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
     ForecastPowerUltraShortTerm forecastPowerUltraShortTerm;
     //获取系统参数cdqjsfs,超短期计算方式,0为默认乘系数的方式,1为根据可用功率计算的方式
@@ -310,7 +300,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     List<PowerStationStatusData> filterList = powerStationStatusDataList.stream().filter(t -> t.getAbleValue().compareTo(new BigDecimal("-1")) == 1).collect(Collectors.toList());
     String coe = super.getSysParameter("CDQ_COE", "1.05", stationCode);
 
-    Long monentTime = 0L;
+    long monentTime = 0L;
     try {
       monentTime = DateMomentUtil.getMomentTime(new Date().getTime(), 1, 15 * 60 * 1000L);
     } catch (Exception e) {
@@ -319,7 +309,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     if (filterList.size() > 0) {
       BigDecimal sumAbleValue = filterList.stream().map(PowerStationStatusData::getAbleValue)
         .reduce(BigDecimal.ZERO, BigDecimal::add);
-      BigDecimal averageAbleValue = sumAbleValue.divide(new BigDecimal(filterList.size()), 2, BigDecimal.ROUND_HALF_UP);
+      BigDecimal averageAbleValue = sumAbleValue.divide(new BigDecimal(filterList.size()), 2, RoundingMode.HALF_UP);
       //可用-短期差值
       BigDecimal deviationValue = averageAbleValue.subtract(currentForecastPowerShortTerm.getFpValue());
       for (int i = 1; i < forecastPowerShortTermList.size(); i++) {
@@ -329,7 +319,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         //短期
         stPower = forecastPowerShortTermList.get(i).getFpValue();
         //短期*系数
-        ustPowers = stPower.multiply(new BigDecimal(coe)).setScale(2, BigDecimal.ROUND_HALF_UP);
+        ustPowers = stPower.multiply(new BigDecimal(coe)).setScale(2, RoundingMode.HALF_UP);
         // 如果短期预测小于等于0,则超短期为0
         if (stPower.doubleValue() <= 0) {
           forecastPowerUltraShortTerm.setFpValue(BigDecimal.ZERO);
@@ -337,12 +327,12 @@ public class ForecastPowerUltraShortTermService extends BaseService {
           forecastPowerUltraShortTerm.setCoefficientValue(BigDecimal.ZERO);
           forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
         } else {
-          BigDecimal xzjdq = deviationValue.add(stPower).setScale(2, BigDecimal.ROUND_HALF_UP);
+          BigDecimal xzjdq = deviationValue.add(stPower).setScale(2, RoundingMode.HALF_UP);
           String cdqjsfsZbxz = electricFieldService.getSysParameter("cdqjsfsZbxz", "0.4", stationCode);
           log.debug("参数cdqjsfsZbxz值为:" + cdqjsfsZbxz + ",超短期计算方式,可用和短期的差值加短期占比。");
           String cdqjsfsZbdq = electricFieldService.getSysParameter("cdqjsfsZbdq", "0.6", stationCode);
           log.debug("参数cdqjsfsZbdq值为:" + cdqjsfsZbdq + ",超短期计算方式,短期占比。");
-          ustPower = xzjdq.multiply(new BigDecimal(cdqjsfsZbxz)).setScale(2, BigDecimal.ROUND_HALF_UP).add(stPower.multiply(new BigDecimal(cdqjsfsZbdq)).setScale(2, BigDecimal.ROUND_HALF_UP));
+          ustPower = xzjdq.multiply(new BigDecimal(cdqjsfsZbxz)).setScale(2, RoundingMode.HALF_UP).add(stPower.multiply(new BigDecimal(cdqjsfsZbdq)).setScale(2, RoundingMode.HALF_UP));
           if (ustPower.doubleValue() > capacity.doubleValue()) {
             // 如果超短期结果超出装机容量,则超短期结果为装机容量
             forecastPowerUltraShortTerm.setFpValue(capacity);
@@ -370,12 +360,12 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       // 短期乘以系数
       for (int i = 1; i < forecastPowerShortTermList.size(); i++) {
         stPower = forecastPowerShortTermList.get(i).getFpValue();
-        ustPower = stPower.multiply(new BigDecimal(coe)).setScale(2, BigDecimal.ROUND_HALF_UP);
+        ustPower = stPower.multiply(new BigDecimal(coe)).setScale(2, RoundingMode.HALF_UP);
         forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
         forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
         forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E9);
         forecastPowerUltraShortTerm.setCoefficientValue(ustPower);
-        forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
+        forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, RoundingMode.HALF_UP));
         forecastPowerUltraShortTerm.setFpValue(ustPower);
         forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
         forecastPowerUltraShortTerm.setStationCode(stationCode);
@@ -386,7 +376,6 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     this.forecastPowerUltraShortTermRepository.deleteByForecastTimeBetweenAndStationCode(forecastPowerShortTermList.get(1).getForecastTime(), forecastPowerShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime(), stationCode);
     this.forecastPowerUltraShortTermRepository.saveAll(forecastPowerUltraShortTermList);
 
-    return forecastPowerUltraShortTermList;
   }
 
   private void executeForecastForlight(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity, String stationCode) {
@@ -416,7 +405,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       startTime = startTime - (startTime % timeStep) + timeStep;
     }
     if (list != null && list.size() > 0) {
-      for (Long i = startTime; i < endTime; i = i + timeStep) {
+      for (long i = startTime; i < endTime; i = i + timeStep) {
         long finalI = i;
         List<ForecastPowerUltraShortTermHis> filterList = list.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
         if (filterList != null && filterList.size() > 0) {
@@ -443,7 +432,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public Map<String, Object> findByForecastRealTimeUltraShortTerm16(Long startTime, String stationCode) {
-    Long endTime = startTime + 60 * 60 * 1000 * 24;
+    long endTime = startTime + 60 * 60 * 1000 * 24;
 //    List<Map<String,Object>> valueList16 = new ArrayList<>();
     //取出16点数据存入集合中
     Map<String, Object> realPowerMap = new HashMap<>();
@@ -453,13 +442,11 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       int finalP = p;
       List<ForecastPowerUltraShortTermHis> filterList = forecastPowerUltraShortTermHisList.stream().filter(t -> t.getForecastHowLongAgo() == finalP).collect(Collectors.toList());
 
-      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       long timeStep = 900000L;
       if (startTime % timeStep != 0) {
         startTime = startTime - (startTime % timeStep);
       }
       List<Float> ableDatas = new ArrayList<>();
-      List<String> times = new ArrayList<>();
 
       for (long i = startTime; i < endTime; i = i + 900000L) {
         long finalI = i;

+ 4 - 34
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/HolidayCalendarService.java

@@ -83,39 +83,9 @@ public class HolidayCalendarService extends BaseService {
 
   }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<HolidayCalendar> beans) {
-        holidayCalendarRepository.deleteAll();
-        holidayCalendarRepository.saveAll(beans);
-    }
-
-  /**
-   * 计算出距离当前最近且在当前时间之后的时间
-   * @return
-   */
-  public HolidayCalendar findByNextTime(){
-
-    List<HolidayCalendar> holidayCalendarList = holidayCalendarRepository.findAll();
-    HolidayCalendar holidayCalendar1 = new HolidayCalendar();
-    holidayCalendar1.setStartTime(0l);
-    if(holidayCalendarList.size()>0){
-
-      Long time = System.currentTimeMillis();
-      for(HolidayCalendar holidayCalendar:holidayCalendarList){
-        Long difference = holidayCalendar.getStartTime() - time;
-        if(holidayCalendar.getStartTime()>time){
-          if(holidayCalendar1.getStartTime()==0){
-//          holidayCalendar1.setStartTime(difference);
-            holidayCalendar1 = holidayCalendar;
-          }
-          if(difference>0l&&difference<holidayCalendar1.getStartTime()){
-            holidayCalendar1 = holidayCalendar;
-          }
-        }
-
-      }
-    }
-
-    return holidayCalendar1;
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<HolidayCalendar> beans) {
+    holidayCalendarRepository.deleteAll();
+    holidayCalendarRepository.saveAll(beans);
   }
 }

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

@@ -84,8 +84,7 @@ public class InitJobClassService extends BaseService {
   public boolean deleteById(String ids) {
     boolean flag = false;
     try {
-      if (ids.isEmpty()) {
-      } else {
+      if (!ids.isEmpty()) {
         String[] id = ids.split(",");
         if (null != id && id.length > 0) {
           for (String did : id) {
@@ -119,7 +118,7 @@ public class InitJobClassService extends BaseService {
     //分页信息
     Pageable pageable = PageRequest.of(page - 1, size); //页码:前端从1开始,jpa从0开始,做个转换
     Page pageUser = initJobClassRepository.findAll(specification, pageable);
-    List<InitJobClass> quartzs = pageUser.getContent();// 结果集
+    List quartzs = pageUser.getContent();// 结果集
     map.put("emps", quartzs);// 结果集
     map.put("count", pageUser.getTotalElements());// 总记录数
     return map;

+ 148 - 194
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InverterInfoService.java

@@ -2,20 +2,16 @@ package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.data.entity.InverterInfo;
-import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipfcst.common.data.repository.InverterInfoRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
-import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -31,126 +27,102 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class InverterInfoService extends BaseService {
-    private final InverterInfoRepository inverterInfoRepository;
+  private final InverterInfoRepository inverterInfoRepository;
 
-    @Autowired
-    public InverterInfoService(InverterInfoRepository inverterInfoRepository) {
-        this.inverterInfoRepository = inverterInfoRepository;
-    }
+  @Autowired
+  public InverterInfoService(InverterInfoRepository inverterInfoRepository) {
+    this.inverterInfoRepository = inverterInfoRepository;
+  }
 
 
-    /**
-     * 新增逆变器
-     *
-     * @param inverterInfo 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void add(InverterInfo inverterInfo) throws BusinessException {
-        this.inverterInfoRepository.save(inverterInfo);
-    }
+  /**
+   * 新增逆变器
+   *
+   * @param inverterInfo 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(InverterInfo inverterInfo) throws BusinessException {
+    this.inverterInfoRepository.save(inverterInfo);
+  }
 
 
-    /**
-     * 批量新增逆变器
-     *
-     * @param inverterInfo 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void addALL(InverterInfo inverterInfo, Integer startValue, Integer endValue) throws BusinessException {
-        for (int i = startValue; i < startValue + endValue; i++) {
-          InverterInfo inverterInfo1 = new InverterInfo();
-          inverterInfo1.setManufacturer(inverterInfo.getManufacturer());
-          inverterInfo1.setReport(inverterInfo.getReport());
-          inverterInfo1.setInstallationTime(inverterInfo.getInstallationTime());
-          inverterInfo1.setName(inverterInfo.getName() + "-" + i);
-          inverterInfo1.setBatteryModel(inverterInfo.getBatteryModel());
-          inverterInfo1.setBatteryNumber(inverterInfo.getBatteryNumber());
-          inverterInfo1.setBox(inverterInfo.getBox());
-          inverterInfo1.setCapacity(inverterInfo.getCapacity());
-          inverterInfo1.setCollectorCircuit(inverterInfo.getCollectorCircuit());
-          inverterInfo1.setEfficiency(inverterInfo.getEfficiency());
-          inverterInfo1.setGroupSeries(inverterInfo.getGroupSeries());
-          inverterInfo1.setSample(inverterInfo.getSample());
-          inverterInfo1.setModelNumber(inverterInfo.getModelNumber());
-          inverterInfo1.setInterval(inverterInfo.getInterval());
-          inverterInfo1.setStationCode(inverterInfo.getStationCode());
-          inverterInfo1.setEquipmentNo(inverterInfo.getEquipmentNo());
-          inverterInfo1.setBackupA(inverterInfo.getBackupA());
-          inverterInfo1.setBackupB(inverterInfo.getBackupB());
-          inverterInfo1.setBackupC(inverterInfo.getBackupC());
-          this.inverterInfoRepository.save(inverterInfo1);
-        }
+  /**
+   * 批量新增逆变器
+   *
+   * @param inverterInfo 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void addALL(InverterInfo inverterInfo, Integer startValue, Integer endValue) throws BusinessException {
+    for (int i = startValue; i < startValue + endValue; i++) {
+      InverterInfo inverterInfo1 = new InverterInfo();
+      inverterInfo1.setManufacturer(inverterInfo.getManufacturer());
+      inverterInfo1.setReport(inverterInfo.getReport());
+      inverterInfo1.setInstallationTime(inverterInfo.getInstallationTime());
+      inverterInfo1.setName(inverterInfo.getName() + "-" + i);
+      inverterInfo1.setCapacity(inverterInfo.getCapacity());
+      inverterInfo1.setCollectorCircuit(inverterInfo.getCollectorCircuit());
+      inverterInfo1.setEfficiency(inverterInfo.getEfficiency());
+      inverterInfo1.setGroupSeries(inverterInfo.getGroupSeries());
+      inverterInfo1.setSample(inverterInfo.getSample());
+      inverterInfo1.setModelNumber(inverterInfo.getModelNumber());
+      inverterInfo1.setInterval(inverterInfo.getInterval());
+      inverterInfo1.setStationCode(inverterInfo.getStationCode());
+      inverterInfo1.setEquipmentNo(inverterInfo.getEquipmentNo());
+      inverterInfo1.setBackupA(inverterInfo.getBackupA());
+      inverterInfo1.setBackupB(inverterInfo.getBackupB());
+      inverterInfo1.setBackupC(inverterInfo.getBackupC());
+      this.inverterInfoRepository.save(inverterInfo1);
     }
+  }
 
-    /**
-     * 修改逆变器
-     *
-     * @param inverterInfo 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void update(InverterInfo inverterInfo) throws BusinessException {
-        if (StringUtils.isEmpty(inverterInfo.getId())) {
-            throw new BusinessException("逆变器编号不能为空!");
-        } else {
-            this.inverterInfoRepository.save(inverterInfo);
-        }
+  /**
+   * 修改逆变器
+   *
+   * @param inverterInfo 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(InverterInfo inverterInfo) throws BusinessException {
+    if (StringUtils.isEmpty(inverterInfo.getId())) {
+      throw new BusinessException("逆变器编号不能为空!");
+    } else {
+      this.inverterInfoRepository.save(inverterInfo);
     }
+  }
 
-    /**
-     * 删除逆变器
-     *
-     * @param id 逆变器编号
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void delete(final Integer id) throws BusinessException {
-        if (StringUtils.isEmpty(id)) {
-            throw new BusinessException("逆变器编号不能为空!");
-        } else {
-            this.inverterInfoRepository.deleteById(id);
-        }
+  /**
+   * 删除逆变器
+   *
+   * @param id 逆变器编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void delete(final Integer id) throws BusinessException {
+    if (StringUtils.isEmpty(id)) {
+      throw new BusinessException("逆变器编号不能为空!");
+    } else {
+      this.inverterInfoRepository.deleteById(id);
     }
+  }
 
-    /**
-     * 查询逆变器
-     *
-     * @param id 逆变器编号
-     * @return 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public InverterInfo get(final Integer id) throws BusinessException {
-        Optional<InverterInfo> optional = this.inverterInfoRepository.findById(id);
-        if (optional.isPresent()) {
-            return optional.get();
-        } else {
-            throw new BusinessException("逆变器不存在!");
-        }
+  /**
+   * 查询逆变器
+   *
+   * @param id 逆变器编号
+   * @return 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public InverterInfo get(final Integer id) throws BusinessException {
+    Optional<InverterInfo> optional = this.inverterInfoRepository.findById(id);
+    if (optional.isPresent()) {
+      return optional.get();
+    } else {
+      throw new BusinessException("逆变器不存在!");
     }
-
-    /*
-     *//**
-     * 查询逆变器【分页查询】
-     *
-     * @param inverter 查询条件
-     * @param page     页码
-     * @param size     每页记录数
-     * @return 分页结果
-     *//*
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Page<Inverter> get(final Inverter inverter, final Integer page, final Integer size) {
-        ExampleMatcher matcher = ExampleMatcher.matching()
-                .withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("box", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("collectorCircuit", ExampleMatcher.GenericPropertyMatchers.contains());
-        Example<Inverter> example = Example.of(inverter, matcher);
-        Pageable pageable = PageRequest.of(page - 1, size);
-        return this.inverterRepository.findAll(example, pageable);
-    }*/
-
+  }
 
   /**
    * 查询逆变器【分页查询】
@@ -168,100 +140,82 @@ public class InverterInfoService extends BaseService {
     return this.inverterInfoRepository.findAll(example, pageable);
   }
 
-    /**
-     * 查询逆变器【分页查询】
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<InverterInfo> getAll() {
-        return inverterInfoRepository.findAll();
-    }
-
-
-    /**
-     * 查询所有样板机逆变器 create by xiuwei
-     *
-     * @return 逆变器信息
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<InverterInfo> getAllSample() {
-        InverterInfo inverterInfo = new InverterInfo();
-        inverterInfo.setSample(true);
-        return inverterInfoRepository.findAll(Example.of(inverterInfo));
-    }
-
-
-    /**
-     * 查询条件
-     *
-     * @param sample 是否样板机
-     * @return 查询条件
-     */
-    private Specification<InverterInfo> getDemoQuerySpecification(Boolean sample) {
-        return (Specification<InverterInfo>) (root, criteriaQuery, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            if (null != sample) {
-                predicates.add(cb.equal(root.get("sample").as(Boolean.class), sample));
-            }
+  /**
+   * 查询逆变器【分页查询】
+   *
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<InverterInfo> getAll() {
+    return inverterInfoRepository.findAll();
+  }
 
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-    }
 
+  /**
+   * 查询所有样板机逆变器 create by xiuwei
+   *
+   * @return 逆变器信息
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<InverterInfo> getAllSample() {
+    InverterInfo inverterInfo = new InverterInfo();
+    inverterInfo.setSample(true);
+    return inverterInfoRepository.findAll(Example.of(inverterInfo));
+  }
 
-    /**
-     * 保存光伏组件信息
-     *
-     * @param inverterInfo 光伏组件信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void save(InverterInfo inverterInfo) {
-        this.inverterInfoRepository.save(inverterInfo);
-    }
+  /**
+   * 保存光伏组件信息
+   *
+   * @param inverterInfo 光伏组件信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void save(InverterInfo inverterInfo) {
+    this.inverterInfoRepository.save(inverterInfo);
+  }
 
-    /**
-     * 删除逆变器信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public boolean delete(String ids) {
-        boolean flag = false;
-        if (!StringUtils.isEmpty(ids)) {
-            String[] idArray = ids.split(",");
-            if (idArray != null && idArray.length > 0) {
-                for (String id : idArray) {
-                    this.inverterInfoRepository.deleteById(Integer.valueOf(id));
-                    log.info("删除逆变器ID为[" + id + "]成功!");
+  /**
+   * 删除逆变器信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public boolean delete(String ids) {
+    boolean flag = false;
+    if (!StringUtils.isEmpty(ids)) {
+      String[] idArray = ids.split(",");
+      if (idArray != null && idArray.length > 0) {
+        for (String id : idArray) {
+          this.inverterInfoRepository.deleteById(Integer.valueOf(id));
+          log.info("删除逆变器ID为[" + id + "]成功!");
 
-                }
-                flag = true;
-            } else {
-                this.inverterInfoRepository.deleteById(Integer.valueOf(ids));
-                flag = true;
-                log.info("删除逆变器ID为[" + ids + "]成功!");
-            }
         }
+        flag = true;
+      } else {
+        this.inverterInfoRepository.deleteById(Integer.valueOf(ids));
+        flag = true;
+        log.info("删除逆变器ID为[" + ids + "]成功!");
+      }
+    }
 
-        return flag;
+    return flag;
 
-    }
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(InverterInfo bean) {
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(InverterInfo bean) {
 //        InverterInfo inverterInfo = inverterInfoRepository.findByName(bean.getName());
 //        if (null != inverterInfo) {
 //            bean.setId(inverterInfo.getId());
 //        }
-        inverterInfoRepository.save(bean);
-    }
+    inverterInfoRepository.save(bean);
+  }
 
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<InverterInfo> beans) {
-        if(beans != null && beans.size() > 0){
-            inverterInfoRepository.deleteAll();
-            inverterInfoRepository.saveAll(beans);
-        }
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<InverterInfo> beans) {
+    if (beans != null && beans.size() > 0) {
+      inverterInfoRepository.deleteAll();
+      inverterInfoRepository.saveAll(beans);
     }
+  }
 
   /**
    * 根据场站编号查询逆变器
@@ -272,10 +226,10 @@ public class InverterInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<InverterInfo> getByStationCode(String stationCode) {
-    List<InverterInfo> resultList = new ArrayList<>();
-    resultList =  this.inverterInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<InverterInfo> resultList;
+    resultList = this.inverterInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(InverterInfo::getStationCode)).collect(Collectors.toList());
   }

+ 10 - 103
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/InverterStatusDataService.java

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
 import java.util.*;
@@ -34,109 +33,26 @@ public class InverterStatusDataService {
     this.inverterStatusDataRepository = inverterStatusDataRepository;
   }
 
-
   /**
    * 根据时间和编号 分页查询 逆变器数据 yh
    *
-   * @param startTime     开始时间
-   * @param endTime       结束时间
-   * @param no            设备编号
-   * @param page          页码
-   * @param size          条数
-   * @param timeSortOrder 排序
-   * @param noSortOrder   排序
+   * @param startTime  开始时间
+   * @param endTime    结束时间
+   * @param page       页码
+   * @param size       条数
+   * @param inverterId 设备编号
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenAndNoForPaging(Date startTime, Date endTime,
-                                                             Integer page, Integer size,
-                                                             Integer[] no, String timeSortOrder, String noSortOrder) {
-    Map<String, Object> map = new HashMap<>();
-    List<Sort.Order> orders = new ArrayList<Sort.Order>();
-
-    if (timeSortOrder.indexOf("asc") >= 0) {
-      orders.add(new Sort.Order(Sort.Direction.ASC, "time"));
-    } else {
-      orders.add(new Sort.Order(Sort.Direction.DESC, "time"));
-    }
-
-    if (noSortOrder.indexOf("asc") >= 0) {
-      orders.add(new Sort.Order(Sort.Direction.ASC, "equipmentNo"));
-    } else {
-      orders.add(new Sort.Order(Sort.Direction.DESC, "equipmentNo"));
-    }
-
-    Sort sort = Sort.by(orders);
-    Specification<InverterStatusData> specification = this.specificationFindByTimeAndNo(startTime, endTime, no);
-    Pageable pageable = PageRequest.of(page - 1, size, sort);
-    Page inverterStatusDatas = inverterStatusDataRepository.findAll(specification, pageable);
-    List<InverterStatusData> datas = new ArrayList<>();
-    datas = inverterStatusDatas.getContent();
-    this.defaultReplace(datas);
-    map.put("content", datas);
-    map.put("count", inverterStatusDatas.getTotalElements());
-    return map;
-  }
-
-  /**
-   * 根据时间和编号 分页查询条件 yh
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   * @param no        设备编号
-   * @return 过滤条件
-   */
-  Specification<InverterStatusData> specificationFindByTimeAndNo(final Date startTime, final Date endTime, final Integer[] no) {
-    return (Specification<InverterStatusData>) (root, criteriaQuery, cb) -> {
-      List<Predicate> predicates = new ArrayList<>();
-      if (startTime != null) {
-        //大于或等于传入时间
-        predicates.add(cb.greaterThanOrEqualTo(root.get("time").as(Date.class), startTime));
-      }
-      if (endTime != null) {
-        //小于传入时间
-        predicates.add(cb.lessThan(root.get("time").as(Date.class), endTime));
-      }
-
-//            if(no!=null){
-//              predicates.add(cb.equal(root.get("equipmentNo").as(Integer.class), no));
-//            }
-      if (no != null) {
-        List<Predicate> list = new ArrayList<Predicate>();
-        CriteriaBuilder.In<Integer> in = cb.in(root.get("equipmentNo"));
-        for (int i = 0; i < no.length; i++) {
-          in.value(no[i]);
-        }
-        predicates.add(in);
-      }
-
-      //添加排序的功能
-      return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-
-    };
-  }
-
-
-  /**
-   * 根据时间和编号 分页查询 逆变器数据 yh
-   *
-   * @param startTime     开始时间
-   * @param endTime       结束时间
-   * @param page          页码
-   * @param size          条数
-   * @param inverterId   设备编号
-   * @return
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenForPaging(String stationCode,Date startTime, Date endTime,
+  public Map<String, Object> findByTimeBetweenForPaging(String stationCode, Date startTime, Date endTime,
                                                         Integer page, Integer size,
                                                         String inverterId) {
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<InverterStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,inverterId);
+    Specification<InverterStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, inverterId);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page inverterStatusDatas = inverterStatusDataRepository.findAll(specification, pageable);
-    List<InverterStatusData> datas = new ArrayList<>();
+    List<InverterStatusData> datas;
     datas = inverterStatusDatas.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);// 结果集
@@ -151,11 +67,11 @@ public class InverterStatusDataService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<InverterStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime,final String inverterId) {
+  Specification<InverterStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String inverterId) {
     return (Specification<InverterStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(inverterId)){
+      if (!"ALL".equals(inverterId)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), inverterId));
       }
       if (startTime != null) {
@@ -202,14 +118,5 @@ public class InverterStatusDataService {
         i.setDayGridConnectedHours(null);
       }
     }
-
-  }
-
-
-  public List<InverterStatusData> findByTimeBetweenAndNo(Long startTime, Long endTime, Integer[] no) {
-    List<InverterStatusData> inverterStatusData = inverterStatusDataRepository.findByTimeBetweenAndEquipmentIdIn(new Date(startTime), new Date(endTime), no);
-
-    return inverterStatusData;
   }
-
 }

+ 75 - 181
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/NwpService.java

@@ -5,14 +5,11 @@ import com.jiayue.ipfcst.common.core.util.CommonUtil;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.Nwp;
-import com.jiayue.ipfcst.common.data.entity.NwpHis;
 import com.jiayue.ipfcst.common.data.repository.NwpHisRepository;
 import com.jiayue.ipfcst.common.data.repository.NwpRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
-import com.sun.istack.internal.NotNull;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.DateFormatUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -25,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -62,141 +60,37 @@ public class NwpService extends BaseService {
     nwpRepository.saveAll(listNwp);
   }
 
-  /**
-   * 查询NWP数据,当查询结果不足时,需要本地化生成NWP数据并保存到数据库中,用于NWP数据上报时使用
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   * @return NWP数据结果集
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  public List<Nwp> getNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
-    log.info("开始获取NWP数据" + DateFormatUtils.format(startTime, "yyyy-MM-dd HH:mm:ss") + " 至 " + DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
-    // 查询NWP数据
-    List<Nwp> nwpDataList = this.nwpRepository.findByPreTimeBetween(startTime, endTime);
-    nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));// 按预测时间升序
-    log.info("查询现有NWP数据记录数:" + nwpDataList.size());
-    // 判断查询结果是否满足查询所需
-    Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
-    Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
-    log.info("获取所需记录数:" + moments);
-    if (moments > nwpDataList.size()) {
-      // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
-      Map<Long, List<Nwp>> nwpDataMap = nwpDataList.stream().collect(Collectors.groupingBy(Nwp::getPreTime));
-      // 如果查询结果少于所需预测数,则进行本地化计算,补齐预测记录
-      List<Nwp> addNwpDataList = new ArrayList<>();
-      for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
-        if (nwpDataMap.get(tempTime) == null) {
-          // 缺失时间点
-          List<Nwp> _nwpDataList = this.generateNwpData(tempTime);
-          addNwpDataList.addAll(_nwpDataList);
-        }
-      }
-
-      if (!addNwpDataList.isEmpty()) {
-        this.nwpRepository.saveAll(addNwpDataList);
-        // 将补齐的NWP数据追加到查询结果集中
-        nwpDataList.addAll(addNwpDataList);
-        // 进行告警
-        String errorInfo = "NWP数据不足";
-        log.error(errorInfo);
-        // 进行告警
-        String name = "NWP数据不足";
-        String describe = "";
-        String solution = "请检查NWP数据下载软件";
-        //super.saveSysAlarm(AlarmTypeEnum.E1, name, describe, errorInfo, solution);
-      }
-
-    }
-    // 处理NWP历史数据记录
-    List<NwpHis> nwpDataHiss = new ArrayList<>();
-    NwpHis nwpHis;
-    Long systemTime = new Date().getTime();
-
-    for (Nwp nwp : nwpDataList) {
-      nwpHis = new NwpHis();
-      BeanUtils.copyProperties(nwp, nwpHis);
-      // 设置提前几天预测
-      nwpHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime, nwpHis.getPreTime()));
-      nwpDataHiss.add(nwpHis);
-    }
-    // 按预测时间升序
-    nwpDataHiss.sort(Comparator.comparing(NwpHis::getPreTime));
-    // 删除当日生成的短期历史记录
-    this.nwpHisRepository.deleteToday(startTime, endTime);
-    // 保存NWP历史记录
-    this.nwpHisRepository.saveAll(nwpDataHiss);
-    return nwpDataList;
-  }
-
-  /**
-   * 生成NWP数据,NWP数据为云下载数据,这里不进行覆盖更新,只针对NWP数据不足时补充
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  public void buildNwpData(@NotNull final Long startTime, @NotNull final Long endTime) {
-    this.getNwpData(startTime, endTime);
-  }
-
-  /**
-   * 生成NWP数据
-   *
-   * @return nwp数据集
-   */
-  @Transactional(propagation = Propagation.REQUIRED)
-  private List<Nwp> generateNwpData(@NotNull final Long tempTime) {
-
-    List<Nwp> nwpDataList;
-
-    // 使用历史NWP数据生成NWP数据
-    List<Nwp> result = new ArrayList<>();
-    // 查询前一天同时刻NWP数据
-    nwpDataList = this.nwpRepository.findByPreTimeBetween(tempTime - 24 * 60 * 60 * 1000L, tempTime - 24 * 50 * 60 * 1000L);
-    if (nwpDataList.size() > 0) {
-      Nwp nwp = new Nwp();
-      BeanUtils.copyProperties(nwpDataList.get(0), nwp, "id");
-      nwp.setPreTime(tempTime);
-      nwp.setPreDate(DateFormatUtils.format(tempTime, "yyyy-MM-dd"));
-      result.add(nwp);
-    } else {// 如果未查询到前一天数据,则随机生成NWP数据
-      result.add(this.createNwpData(tempTime));
-    }
-    return result;
-  }
-
   private Nwp createNwpData(Long preTime) {
-    Long systemTime = System.currentTimeMillis();
+    long systemTime = System.currentTimeMillis();
     Nwp nwpData = new Nwp();
     nwpData.setFarmId("1");
     nwpData.setScDate(DateFormatUtils.format(systemTime, "yyyy-MM-dd"));
     nwpData.setScTime(DateFormatUtils.format(systemTime, "HH:mm:ss"));
     nwpData.setPreTime(preTime);
     nwpData.setPreDate(DateFormatUtils.format(preTime, "yyyy-MM-dd"));
-    nwpData.setPressure(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setT(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setRh(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setSenf(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setSwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setLwr(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-
-    nwpData.setWd10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWd170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs10(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs30(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs50(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs70(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs80(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs90(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs100(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
-    nwpData.setWs170(new BigDecimal(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, BigDecimal.ROUND_UP));
+    nwpData.setPressure(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setT(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setRh(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setSenf(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setSwr(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setLwr(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+
+    nwpData.setWd10(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd30(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd50(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd70(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd80(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd90(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd100(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWd170(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs10(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs30(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs50(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs70(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs80(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs90(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs100(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
+    nwpData.setWs170(BigDecimal.valueOf(CommonUtil.getRandom(1, 5000) / 10.0).setScale(2, RoundingMode.UP));
     return nwpData;
   }
 
@@ -401,7 +295,7 @@ public class NwpService extends BaseService {
     Specification<Nwp> specification = specificationFindByTimeAndNo(startTime, endTime, stationCode);
     Pageable pageable = PageRequest.of(page - 1, size, sort);
     Page nwps = nwpRepository.findAll(specification, pageable);
-    List<Nwp> datas = new ArrayList<>();
+    List<Nwp> datas;
     datas = nwps.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);
@@ -464,31 +358,31 @@ public class NwpService extends BaseService {
       BigDecimal wd90 = new BigDecimal(0);
       BigDecimal wd100 = new BigDecimal(0);
       BigDecimal wd170 = new BigDecimal(0);
-      for (int j = 0; j < nwpList.size(); j++) {
-        t = t.add(nwpList.get(j).getT() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getT());
-        rh = rh.add(nwpList.get(j).getRh() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getRh());
-        pressure = pressure.add(nwpList.get(j).getPressure() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getPressure());
-        swr = swr.add(nwpList.get(j).getSwr() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getSwr());
-        lwr = lwr.add(nwpList.get(j).getLwr() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getLwr());
-        directRadiation = directRadiation.add(nwpList.get(j).getDirectRadiation() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getDirectRadiation());
-        diffuseRadiation = diffuseRadiation.add(nwpList.get(j).getDiffuseRadiation() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getDiffuseRadiation());
-        senf = senf.add(nwpList.get(j).getSenf() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getSenf());
-        ws10 = ws10.add(nwpList.get(j).getWs10() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs10());
-        ws30 = ws30.add(nwpList.get(j).getWs30() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs30());
-        ws50 = ws50.add(nwpList.get(j).getWs50() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs50());
-        ws70 = ws70.add(nwpList.get(j).getWs70() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs70());
-        ws80 = ws80.add(nwpList.get(j).getWs80() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs80());
-        ws90 = ws90.add(nwpList.get(j).getWs90() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs90());
-        ws100 = ws100.add(nwpList.get(j).getWs100() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs100());
-        ws170 = ws170.add(nwpList.get(j).getWs170() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWs170());
-        wd10 = wd10.add(nwpList.get(j).getWd10() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd10());
-        wd30 = wd30.add(nwpList.get(j).getWd30() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd30());
-        wd50 = wd50.add(nwpList.get(j).getWd50() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd50());
-        wd70 = wd70.add(nwpList.get(j).getWd70() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd70());
-        wd80 = wd80.add(nwpList.get(j).getWd80() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd80());
-        wd90 = wd90.add(nwpList.get(j).getWd90() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd90());
-        wd100 = wd100.add(nwpList.get(j).getWd100() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd100());
-        wd170 = wd170.add(nwpList.get(j).getWd170() == null ? BigDecimal.valueOf(0) : nwpList.get(j).getWd170());
+      for (Nwp value : nwpList) {
+        t = t.add(value.getT() == null ? BigDecimal.valueOf(0) : value.getT());
+        rh = rh.add(value.getRh() == null ? BigDecimal.valueOf(0) : value.getRh());
+        pressure = pressure.add(value.getPressure() == null ? BigDecimal.valueOf(0) : value.getPressure());
+        swr = swr.add(value.getSwr() == null ? BigDecimal.valueOf(0) : value.getSwr());
+        lwr = lwr.add(value.getLwr() == null ? BigDecimal.valueOf(0) : value.getLwr());
+        directRadiation = directRadiation.add(value.getDirectRadiation() == null ? BigDecimal.valueOf(0) : value.getDirectRadiation());
+        diffuseRadiation = diffuseRadiation.add(value.getDiffuseRadiation() == null ? BigDecimal.valueOf(0) : value.getDiffuseRadiation());
+        senf = senf.add(value.getSenf() == null ? BigDecimal.valueOf(0) : value.getSenf());
+        ws10 = ws10.add(value.getWs10() == null ? BigDecimal.valueOf(0) : value.getWs10());
+        ws30 = ws30.add(value.getWs30() == null ? BigDecimal.valueOf(0) : value.getWs30());
+        ws50 = ws50.add(value.getWs50() == null ? BigDecimal.valueOf(0) : value.getWs50());
+        ws70 = ws70.add(value.getWs70() == null ? BigDecimal.valueOf(0) : value.getWs70());
+        ws80 = ws80.add(value.getWs80() == null ? BigDecimal.valueOf(0) : value.getWs80());
+        ws90 = ws90.add(value.getWs90() == null ? BigDecimal.valueOf(0) : value.getWs90());
+        ws100 = ws100.add(value.getWs100() == null ? BigDecimal.valueOf(0) : value.getWs100());
+        ws170 = ws170.add(value.getWs170() == null ? BigDecimal.valueOf(0) : value.getWs170());
+        wd10 = wd10.add(value.getWd10() == null ? BigDecimal.valueOf(0) : value.getWd10());
+        wd30 = wd30.add(value.getWd30() == null ? BigDecimal.valueOf(0) : value.getWd30());
+        wd50 = wd50.add(value.getWd50() == null ? BigDecimal.valueOf(0) : value.getWd50());
+        wd70 = wd70.add(value.getWd70() == null ? BigDecimal.valueOf(0) : value.getWd70());
+        wd80 = wd80.add(value.getWd80() == null ? BigDecimal.valueOf(0) : value.getWd80());
+        wd90 = wd90.add(value.getWd90() == null ? BigDecimal.valueOf(0) : value.getWd90());
+        wd100 = wd100.add(value.getWd100() == null ? BigDecimal.valueOf(0) : value.getWd100());
+        wd170 = wd170.add(value.getWd170() == null ? BigDecimal.valueOf(0) : value.getWd170());
       }
       if (nwpList.size() > 0) {
         nwp.setScTime(nwpList.get(0).getScTime());
@@ -496,30 +390,30 @@ public class NwpService extends BaseService {
         nwp.setPreTime(nwpList.get(0).getPreTime());
         nwp.setPreDate(nwpList.get(0).getPreDate());
         nwp.setFarmId(nwpList.get(0).getFarmId());
-        nwp.setT(t.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : t.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setRh(rh.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : rh.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setPressure(pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setSwr(swr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : swr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setLwr(lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setDirectRadiation(directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setDiffuseRadiation(diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setSenf(senf.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : senf.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs10(ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs30(ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs50(ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs70(ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs80(ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs90(ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs100(ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWs170(ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd10(wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd30(wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd50(wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd70(wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd80(wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd90(wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd100(wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
-        nwp.setWd170(wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, BigDecimal.ROUND_HALF_UP));
+        nwp.setT(t.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : t.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setRh(rh.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : rh.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setPressure(pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : pressure.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setSwr(swr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : swr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setLwr(lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : lwr.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setDirectRadiation(directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : directRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setDiffuseRadiation(diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : diffuseRadiation.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setSenf(senf.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : senf.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs10(ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs30(ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs50(ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs70(ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs80(ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs90(ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs100(ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWs170(ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : ws170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd10(wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd10.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd30(wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd30.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd50(wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd50.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd70(wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd70.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd80(wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd80.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd90(wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd90.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd100(wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd100.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
+        nwp.setWd170(wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP).doubleValue() < 0d ? new BigDecimal(0) : wd170.divide(BigDecimal.valueOf(nwpList.size()), 2, RoundingMode.HALF_UP));
         dataList.add(nwp);
       }
     }

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

@@ -2,7 +2,6 @@ package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.data.entity.OverhaulPlan;
-import com.jiayue.ipfcst.common.data.repository.ElectricFieldRepository;
 import com.jiayue.ipfcst.common.data.repository.OverhaulPlanRepository;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,12 +27,9 @@ import java.util.List;
 public class OverHaulPlanService {
   private final OverhaulPlanRepository overhaulPlanRepository;
 
-  private final ElectricFieldRepository electricFieldRepository;
-
   @Autowired
-  public OverHaulPlanService(OverhaulPlanRepository overhaulPlanRepository, ElectricFieldRepository electricFieldRepository) {
+  public OverHaulPlanService(OverhaulPlanRepository overhaulPlanRepository) {
     this.overhaulPlanRepository = overhaulPlanRepository;
-    this.electricFieldRepository = electricFieldRepository;
   }
 
   /**
@@ -104,14 +100,14 @@ public class OverHaulPlanService {
   }
 
 
-  public BigDecimal getOverhaulCapacityByStationCode(String stationCode){
-      BigDecimal overhaulCapacity = new BigDecimal(0);
-      long time = System.currentTimeMillis();
-      List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findByStartTimeLessThanAndEndTimeGreaterThanAndStatusAndStationCode(time, time, 1,stationCode);
-      if(overhaulPlans.size()>0){
-        overhaulCapacity = overhaulPlans.get(0).getOverhaulCapactity();
-      }
-      return overhaulCapacity;
+  public BigDecimal getOverhaulCapacityByStationCode(String stationCode) {
+    BigDecimal overhaulCapacity = new BigDecimal(0);
+    long time = System.currentTimeMillis();
+    List<OverhaulPlan> overhaulPlans = overhaulPlanRepository.findByStartTimeLessThanAndEndTimeGreaterThanAndStatusAndStationCode(time, time, 1, stationCode);
+    if (overhaulPlans.size() > 0) {
+      overhaulCapacity = overhaulPlans.get(0).getOverhaulCapactity();
+    }
+    return overhaulCapacity;
   }
 
   /**

+ 68 - 69
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PvModuleModelService.java

@@ -1,6 +1,5 @@
 package com.jiayue.ipfcst.console.service;
 
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.PvModuleModel;
 import com.jiayue.ipfcst.common.data.repository.PvModuleModelRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
@@ -28,73 +27,73 @@ import java.util.Map;
 @Slf4j
 public class PvModuleModelService extends BaseService {
 
-    private final PvModuleModelRepository pvModuleModelRepository;
+  private final PvModuleModelRepository pvModuleModelRepository;
 
-    @Autowired
-    public PvModuleModelService(PvModuleModelRepository pvModuleModelRepository) {
-        this.pvModuleModelRepository = pvModuleModelRepository;
-    }
+  @Autowired
+  public PvModuleModelService(PvModuleModelRepository pvModuleModelRepository) {
+    this.pvModuleModelRepository = pvModuleModelRepository;
+  }
 
-    /**
-     * 获取所有光伏组件信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public List<PvModuleModel> getAll() {
-        return this.pvModuleModelRepository.findAll();
-    }
+  /**
+   * 获取所有光伏组件信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public List<PvModuleModel> getAll() {
+    return this.pvModuleModelRepository.findAll();
+  }
 
-    /**
-     * 保存光伏组件信息
-     *
-     * @param pvModuleModel 光伏组件信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void save(PvModuleModel pvModuleModel) {
-        this.pvModuleModelRepository.save(pvModuleModel);
-    }
+  /**
+   * 保存光伏组件信息
+   *
+   * @param pvModuleModel 光伏组件信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void save(PvModuleModel pvModuleModel) {
+    this.pvModuleModelRepository.save(pvModuleModel);
+  }
 
-    /**
-     * 删除场站信息
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public boolean delete(String ids) {
-        boolean flag = false;
-        if (!StringUtils.isEmpty(ids)) {
-            String[] idArray = ids.split(",");
-            if (idArray != null && idArray.length > 0) {
-                for (String id : idArray) {
-                    this.pvModuleModelRepository.deleteById(Integer.valueOf(id));
-                    log.info("删除光伏组件ID为[" + id + "]成功!");
+  /**
+   * 删除场站信息
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public boolean delete(String ids) {
+    boolean flag = false;
+    if (!StringUtils.isEmpty(ids)) {
+      String[] idArray = ids.split(",");
+      if (idArray != null && idArray.length > 0) {
+        for (String id : idArray) {
+          this.pvModuleModelRepository.deleteById(Integer.valueOf(id));
+          log.info("删除光伏组件ID为[" + id + "]成功!");
 
-                }
-                flag = true;
-            } else {
-                this.pvModuleModelRepository.deleteById(Integer.valueOf(ids));
-                flag = true;
-                log.info("删除光伏组件ID为[" + ids + "]成功!");
-            }
         }
+        flag = true;
+      } else {
+        this.pvModuleModelRepository.deleteById(Integer.valueOf(ids));
+        flag = true;
+        log.info("删除光伏组件ID为[" + ids + "]成功!");
+      }
+    }
 
-        return flag;
+    return flag;
 
-    }
+  }
 
-    /**
-     * 查询场站信息
-     *
-     * @return 场站信息
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Map<String, Object> get(@RequestParam(defaultValue = "1") Integer page,
-                                   @RequestParam(defaultValue = "10") Integer size) {
-        Map<String, Object> map = new HashMap<>();
-        Sort sort = Sort.by(Sort.Direction.ASC, "id");
-        Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
-        Page pagepvModuleModel = pvModuleModelRepository.findAll(pageable);
-        map.put("content", pagepvModuleModel.getContent());// 结果集
-        map.put("count", pagepvModuleModel.getTotalElements());// 总记录数
-        return map;
-    }
+  /**
+   * 查询场站信息
+   *
+   * @return 场站信息
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Map<String, Object> get(@RequestParam(defaultValue = "1") Integer page,
+                                 @RequestParam(defaultValue = "10") Integer size) {
+    Map<String, Object> map = new HashMap<>();
+    Sort sort = Sort.by(Sort.Direction.ASC, "id");
+    Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
+    Page pagepvModuleModel = pvModuleModelRepository.findAll(pageable);
+    map.put("content", pagepvModuleModel.getContent());// 结果集
+    map.put("count", pagepvModuleModel.getTotalElements());// 总记录数
+    return map;
+  }
 
   /**
    * 查询逆变器【分页查询】
@@ -112,20 +111,20 @@ public class PvModuleModelService extends BaseService {
     return this.pvModuleModelRepository.findAll(example, pageable);
   }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(PvModuleModel bean) {
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(PvModuleModel bean) {
 //        PvModuleModel beanOld = pvModuleModelRepository.findByModel(bean.getModel());
 //        if (null != beanOld) {
 //            bean.setId(beanOld.getId());
 //        }
-        pvModuleModelRepository.save(bean);
-    }
+    pvModuleModelRepository.save(bean);
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<PvModuleModel> beans) {
-        if(beans != null && beans.size() > 0){
-            pvModuleModelRepository.deleteAll();
-            pvModuleModelRepository.saveAll(beans);
-        }
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<PvModuleModel> beans) {
+    if (beans != null && beans.size() > 0) {
+      pvModuleModelRepository.deleteAll();
+      pvModuleModelRepository.saveAll(beans);
     }
+  }
 }

+ 7 - 3
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzJobFactory.java

@@ -13,18 +13,22 @@ import org.springframework.stereotype.Service;
  * @version 2.0
  * @since 2018/10/11 11:24
  */
-@Service public class QuartzJobFactory extends SpringBeanJobFactory {
+@Service
+public class QuartzJobFactory extends SpringBeanJobFactory {
 
   private final AutowireCapableBeanFactory beanFactory;
 
-  @Autowired public QuartzJobFactory(AutowireCapableBeanFactory beanFactory) {
+  @Autowired
+  public QuartzJobFactory(AutowireCapableBeanFactory beanFactory) {
     this.beanFactory = beanFactory;
   }
 
   /**
    * 这里覆盖了super的createJobInstance方法,对其创建出来的类再进行autowire。
    */
-  @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
+  @SuppressWarnings("NullableProblems")
+  @Override
+  protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
 
     Object jobInstance = super.createJobInstance(bundle);
 

+ 9 - 23
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/QuartzService.java

@@ -39,6 +39,14 @@ import java.util.Map;
 public class QuartzService extends BaseService {
 
   private final QuartzRepository quartzRepository;
+  @Value("${spring.datasource.druid.username}")
+  private String username;
+  @Value("${spring.datasource.druid.password}")
+  private String password;
+  @Value("${spring.datasource.druid.driver-class-name}")
+  private String driverClassName;
+  @Value("${spring.datasource.druid.url}")
+  private String url;
 
   @Autowired
   public QuartzService(QuartzRepository quartzRepository) {
@@ -48,17 +56,6 @@ public class QuartzService extends BaseService {
   }
 
   /**
-   * 根据任务名查询
-   *
-   * @param jobName 任务名
-   * @return Quartz
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Quartz findByName(String jobName) {
-    return quartzRepository.findByJobName(jobName);
-  }
-
-  /**
    * 根据执行类查询
    *
    * @param executeClass 执行类
@@ -75,6 +72,7 @@ public class QuartzService extends BaseService {
    *
    * @param qt 任务实体
    */
+  @SuppressWarnings({"finally", "ReturnInsideFinallyBlock"})
   @Transactional(propagation = Propagation.REQUIRED)
   public boolean save(Quartz qt) {
     boolean flag = false;
@@ -213,18 +211,6 @@ public class QuartzService extends BaseService {
     }
   }
 
-  @Value("${spring.datasource.druid.username}")
-  private String username;
-
-  @Value("${spring.datasource.druid.password}")
-  private String password;
-
-  @Value("${spring.datasource.druid.driver-class-name}")
-  private String driverClassName;
-
-  @Value("${spring.datasource.druid.url}")
-  private String url;
-
   /**
    * 定时任务恢复初始化
    */

+ 196 - 80
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ReceiveDataService.java

@@ -1,27 +1,30 @@
 package com.jiayue.ipfcst.console.service;
 
-import cn.hutool.http.HttpUtil;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
-import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
 import com.jiayue.ipfcst.common.data.entity.*;
-import com.jiayue.ipfcst.common.data.repository.InverterStatusDataRepository;
-import com.jiayue.ipfcst.common.data.repository.WeatherStationStatusDataRepository;
-import com.jiayue.ipfcst.common.data.repository.WindTowerStatusDataRepository;
-import com.jiayue.ipfcst.common.data.repository.WindTurbineStatusDataRepository;
-import com.jiayue.ipfcst.console.dto.ResponseResults;
-import com.jiayue.ipfcst.console.dto.ResponseRows;
+import com.jiayue.ipfcst.common.data.repository.*;
 import com.jiayue.ipfcst.console.util.RedisUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Value;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * 接收数据service类
@@ -55,7 +58,17 @@ public class ReceiveDataService {
   RedisUtils redisUtils;
   @Autowired
   EquipmentAttributeService equipmentAttributeService;
+  @Autowired
+  PowerStationStatusDataRepository powerStationStatusDataRepository;
+  @Autowired
+  PowerStationDataPackerContainer powerStationDataPackerContainer;
 
+  @Value("${receive.ip}")
+  private String ip;
+  @Value("${receive.port}")
+  private  String port;
+  @Value("${receive.path}")
+  private  String path;
 
   public void receive() {
     List<ElectricField> electricFieldList = electricFieldService.getAll();
@@ -73,20 +86,10 @@ public class ReceiveDataService {
           List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
           //按设备请求
           for (WeatherStationInfo weatherStationInfo : weatherStationInfoList) {
-            HashMap<String, Object> paramMap = new HashMap<>();
-            paramMap.put("deviceIds", weatherStationInfo.getEquipmentNo());
-            paramMap.put("startTime", startTime);
-            paramMap.put("endTime", endTime);
-            String body = HttpUtil.post("https://10.220.57.13:7085/dataService/v1/getTaosData", paramMap);
-            AnalysisData(body, weatherStationInfo.getId(), weatherStationInfo.getEquipmentType().getCode(), electricField);
+            map(electricField, startTime, endTime, weatherStationInfo.getEquipmentNo(), weatherStationInfo.getId(), weatherStationInfo.getEquipmentType());
           }
           for (InverterInfo inverterInfo : inverterInfoList) {
-            HashMap<String, Object> paramMap = new HashMap<>();
-            paramMap.put("deviceIds", inverterInfo.getEquipmentNo());
-            paramMap.put("startTime", startTime);
-            paramMap.put("endTime", endTime);
-            String body = HttpUtil.post("https://10.220.57.13:7085/dataService/v1/getTaosData", paramMap);
-            AnalysisData(body, inverterInfo.getId(), inverterInfo.getEquipmentType().getCode(), electricField);
+            map(electricField, startTime, endTime, inverterInfo.getEquipmentNo(), inverterInfo.getId(), inverterInfo.getEquipmentType());
           }
         } else {
           //测风塔
@@ -94,84 +97,197 @@ public class ReceiveDataService {
           //风机
           List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
           for (WindTowerInfo windTowerInfo : windTowerInfoList) {
-            HashMap<String, Object> paramMap = new HashMap<>();
-            paramMap.put("deviceIds", windTowerInfo.getEquipmentNo());
-            paramMap.put("startTime", startTime);
-            paramMap.put("endTime", endTime);
-            String body = HttpUtil.post("https://10.220.57.13:7085/dataService/v1/getTaosData", paramMap);
-            AnalysisData(body, windTowerInfo.getId(), windTowerInfo.getEquipmentType().getCode(), electricField);
+            map(electricField, startTime, endTime, windTowerInfo.getEquipmentNo(), windTowerInfo.getId(), windTowerInfo.getEquipmentType());
           }
           for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
-            HashMap<String, Object> paramMap = new HashMap<>();
-            paramMap.put("deviceIds", windTurbineInfo.getEquipmentNo());
-            paramMap.put("startTime", startTime);
-            paramMap.put("endTime", endTime);
-            String body = HttpUtil.post("https://10.220.57.13:7085/dataService/v1/getTaosData", paramMap);
-            AnalysisData(body, windTurbineInfo.getId(), windTurbineInfo.getEquipmentType().getCode(), electricField);
+            map(electricField, startTime, endTime, windTurbineInfo.getEquipmentNo(), windTurbineInfo.getId(), windTurbineInfo.getEquipmentType());
           }
         }
+        savePowerStationStatusData(electricField);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 
+  private void map(ElectricField electricField, Long startTime, Long endTime, String equipmentNo, Integer id, EquipmentTypeEnum equipmentType) {
+    HashMap<String, Object> paramMap = new HashMap<>();
+    paramMap.put("deviceIds", equipmentNo);
+    paramMap.put("startTime", startTime);
+    paramMap.put("endTime", endTime);
+    String body = httpClient(paramMap);
+    AnalysisData(body, id, equipmentType, electricField);
+  }
+
   /**
    * 解析数据
    *
-   * @param boby          所有数据
+   * @param body          所有数据
    * @param equipmentId   设备id
    * @param equipmentType 设备类型
    * @param electricField 场站对象
    */
-  public void AnalysisData(String boby, Integer equipmentId, Integer equipmentType, ElectricField electricField) throws BusinessException {
-    List<DataPoint> dataPointList = dataPointService.getByEquipmentType(equipmentType);
-    JSONObject jsonObject = JSONUtil.parseObj(boby);
-    ResponseResults results = (ResponseResults) jsonObject.get("results");
-    ResponseRows rows = results.getRows();
-    String[] value = rows.getValues();
-    String[] sensorIds = results.getSensorIds();
-    Map<String, String> map = new HashMap<>();
-    map.put("equipmentNo", equipmentId.toString());
-    map.put("time", new Date(rows.getTimestamp()).toString());
-    for (DataPoint dataPoint : dataPointList) {
-      for (int i = 0; i < sensorIds.length; i++) {
-        if (dataPoint.getMeasuringPoint().equals(sensorIds[i])) {
-          map.put(dataPoint.getEquipmentAttribute().getFieldName(), value[i]);
+  public void AnalysisData(String body, Integer equipmentId, EquipmentTypeEnum equipmentType, ElectricField electricField) {
+    try {
+      List<DataPoint> dataPointList = dataPointService.getByEquipmentType(equipmentType);
+      JSONObject jsonObject= JSON.parseObject(body);
+      JSONArray jsonResults = (JSONArray) jsonObject.get("results");
+      JSONObject jsonObj = jsonResults.getJSONObject(0);
+      JSONArray jsonRows = (JSONArray) jsonObj.get("rows");
+      //所有设备点位
+      JSONArray sensorIds = (JSONArray) jsonObj.get("sensorIds");
+      JSONObject values;
+      Map<String, String> map = new HashMap<>();
+      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+      if (jsonRows.size()>0){
+        values = jsonRows.getJSONObject(0);
+        //设备id
+        //String deviceId = jsonObj.getString("deviceId");
+        //时间戳
+        String time = values.getString("timestamp");
+        //所有数据
+        JSONArray jsonValues = (JSONArray) values.get("values");
+        long timestamp = Long.parseLong(time);
+        map.put("stationCode",electricField.getStationCode());
+        map.put("equipmentId", equipmentId.toString());
+        map.put("time", simpleDateFormat.format(timestamp));
+
+        for (DataPoint dataPoint : dataPointList) {
+          for (int i = 0; i < sensorIds.size(); i++) {
+            if (dataPoint.getMeasuringPoint().equals(sensorIds.get(i))) {
+              if(jsonValues.get(i) == null ){
+                map.put(dataPoint.getEquipmentAttribute().getFieldName(), "-99");
+              }else{
+                map.put(dataPoint.getEquipmentAttribute().getFieldName(), jsonValues.get(i).toString());
+              }
+            }
+          }
         }
+        switch (map.get("status")) {
+          case "1.00":
+          case "true":
+            //运行
+            map.put("status", "1");
+            break;
+          case "2.00":
+            //待机
+            map.put("status", "2");
+            break;
+          case "3.00":
+            //停用
+            map.put("status", "3");
+            break;
+          case "4.00":
+          case "false":
+            //故障
+            map.put("status", "4");
+            break;
+          case "-99":
+            map.put("status", "5");
+            break;
+        }
+        switch(equipmentType.getCode()){
+          case 1:
+            //气象站
+            redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
+            WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
+            weatherStationStatusDataRepository.save(weatherStationStatusData);
+            log.info("qxz-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+            break;
+          case 2:
+            //逆变器
+            if (map.get("activePower") != null && map.get("electricalCurrent") != null) {
+              //有功
+              BigDecimal activePower = new BigDecimal(map.get("activePower"));
+              //电流
+              BigDecimal electricalCurrent = new BigDecimal(map.get("electricalCurrent"));
+              //有功/电流=电压
+              BigDecimal voltage = activePower.divide(electricalCurrent, 2, BigDecimal.ROUND_HALF_UP);
+              map.put("voltage", voltage.toString());
+            }
+            redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
+            InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
+            inverterStatusDataRepository.save(inverterStatusData);
+            log.info("nbq-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+            break;
+          case 3:
+            redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
+            WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
+            windTurbineStatusDataRepository.save(windTurbineStatusData);
+            log.info("fj-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+            break;
+          case 4:
+            redisUtils.hmset("cft-" + electricField.getStationCode() + "-" + equipmentId, map);
+            WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
+            windTowerStatusDataRepository.save(windTowerStatusData);
+            log.info("cft-" + electricField.getStationCode() + "-" + equipmentId+"已存入");
+            break;
+        }
+      }else {
+        log.info(electricField.getStationCode()+ "-" +equipmentType.getMessage() + "-" + equipmentId+"无数据,不进行任何操作");
       }
+
+    } catch (Exception e) {
+      log.info("接数程序异常");
+      e.printStackTrace();
     }
-    //光
-    if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
-      WeatherStationInfo weatherStationInfo = weatherStationInfoService.get(equipmentId);
-      if (weatherStationInfo != null) {
-        redisUtils.hmset("qxz-" + electricField.getStationCode() + "-" + equipmentId, map);
-        WeatherStationStatusData weatherStationStatusData = JSON.parseObject(JSON.toJSONString(map), WeatherStationStatusData.class);
-        weatherStationStatusDataRepository.save(weatherStationStatusData);
-      } else {
-        InverterInfo inverterInfo = inverterInfoService.get(equipmentId);
-        if (inverterInfo != null) {
-          redisUtils.hmset("nbq-" + electricField.getStationCode() + "-" + equipmentId, map);
-          InverterStatusData inverterStatusData = JSON.parseObject(JSON.toJSONString(map), InverterStatusData.class);
-          inverterStatusDataRepository.save(inverterStatusData);
+  }
+
+  /**
+   * 发http请求
+   * @param paramMap 参数
+   * @return 返回的数据
+   */
+  public String httpClient( HashMap<String, Object> paramMap){
+    String body = "";
+    try{
+      CloseableHttpClient  httpClient = HttpClientBuilder.create().build();
+      HttpPost httpPost = new HttpPost("http://"+ip+":"+port+path);
+      StringEntity entity = new StringEntity(JSON.toJSONString(paramMap),"UTF-8");
+      httpPost.setEntity(entity);
+      httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
+      CloseableHttpResponse response;
+      response = httpClient.execute(httpPost);
+      HttpEntity responseEntity = response.getEntity();
+      body = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
+    }catch (Exception e){
+      e.printStackTrace();
+    }
+    return body;
+  }
+  public void savePowerStationStatusData(ElectricField electricField) {
+    try {
+      log.info("开始计算实际功率");
+      BigDecimal powerStationStatusData = new BigDecimal("0");
+      if (electricField.getElectricFieldTypeEnum().getCode() == 1) {
+        List<InverterInfo> inverterInfoList = inverterInfoService.getByStationCode(electricField.getStationCode());
+        for (InverterInfo inverterInfo : inverterInfoList) {
+          Map<String, String> getMap = redisUtils.hgetall("nbq-" + electricField.getStationCode() + "-" + inverterInfo.getId());
+          if (getMap.get("activePower") != null) {
+            powerStationStatusData = powerStationStatusData.add(new BigDecimal(getMap.get("activePower")));
+          }
         }
-      }
-    } else {
-      //风
-      WindTurbineInfo windTurbineInfo = windTurbineInfoService.get(equipmentId);
-      if (windTurbineInfo != null) {
-        redisUtils.hmset("fj-" + electricField.getStationCode() + "-" + equipmentId, map);
-        WindTurbineStatusData windTurbineStatusData = JSON.parseObject(JSON.toJSONString(map), WindTurbineStatusData.class);
-        windTurbineStatusDataRepository.save(windTurbineStatusData);
       } else {
-        WindTowerInfo windTowerInfo = windTowerInfoService.get(equipmentId);
-        if (windTowerInfo != null) {
-          redisUtils.hmset("cft-" + electricField.getStationCode() + "-" + equipmentId, map);
-          WindTowerStatusData windTowerStatusData = JSON.parseObject(JSON.toJSONString(map), WindTowerStatusData.class);
-          windTowerStatusDataRepository.save(windTowerStatusData);
+        List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.getByStationCode(electricField.getStationCode());
+        for (WindTurbineInfo windTurbineInfo : windTurbineInfoList) {
+          Map<String, String> getMap = redisUtils.hgetall("fj-" + electricField.getStationCode() + "-" + windTurbineInfo.getId());
+          if (getMap.get("activePower") != null) {
+            powerStationStatusData = powerStationStatusData.add(new BigDecimal(getMap.get("activePower")));
+          }
         }
       }
-
+      if (powerStationStatusData.compareTo(new BigDecimal("0")) > 0) {
+        powerStationStatusData.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP);
+      }
+      PowerStationStatusData p = powerStationDataPackerContainer.getDataPacker(electricField.getStationCode()).packageData(powerStationStatusData);
+      powerStationStatusDataRepository.save(p);
+      //对象转map
+      Map<String, String> map = JSON.parseObject(JSON.toJSONString(p), new TypeReference<Map<String, String>>() {
+      });
+      redisUtils.hmset("power-" + electricField.getStationCode(), map);
+      log.info("实际功率结束");
+    } catch (Exception e) {
+      e.printStackTrace();
     }
   }
 

+ 81 - 90
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/SysParameterService.java

@@ -6,12 +6,6 @@ import com.jiayue.ipfcst.common.data.entity.SysParameter;
 import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.search.Attribute;
-import net.sf.ehcache.search.Query;
-import net.sf.ehcache.search.Result;
-import net.sf.ehcache.search.Results;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.ehcache.EhCacheCacheManager;
 import org.springframework.data.domain.*;
@@ -19,7 +13,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 
@@ -34,88 +27,85 @@ import java.util.Optional;
 @Slf4j
 public class SysParameterService extends BaseService {
 
-    private final SysParameterRepository sysParameterRepository;
+  private final SysParameterRepository sysParameterRepository;
 
-    private final EhCacheCacheManager ehCacheCacheManager;
-
-    @Autowired
-    public SysParameterService(SysParameterRepository sysParameterRepository, EhCacheCacheManager ehCacheCacheManager) {
-        this.sysParameterRepository = sysParameterRepository;
-        this.ehCacheCacheManager = ehCacheCacheManager;
-    }
+  @Autowired
+  public SysParameterService(SysParameterRepository sysParameterRepository, EhCacheCacheManager ehCacheCacheManager) {
+    this.sysParameterRepository = sysParameterRepository;
+  }
 
-    /**
-     * 新增系统参数
-     *
-     * @param sysParameter 系统参数实体
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void add(SysParameter sysParameter) throws BusinessException {
-        boolean b = this.sysParameterRepository.existsBySysKeyAndStationCode(sysParameter.getSysKey(),sysParameter.getStationCode());
-        if (b) {// 参数已存在
-            throw new BusinessException("系统参数已存在!");
-        } else {
-            this.sysParameterRepository.save(sysParameter);
-        }
+  /**
+   * 新增系统参数
+   *
+   * @param sysParameter 系统参数实体
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(SysParameter sysParameter) throws BusinessException {
+    boolean b = this.sysParameterRepository.existsBySysKeyAndStationCode(sysParameter.getSysKey(), sysParameter.getStationCode());
+    if (b) {// 参数已存在
+      throw new BusinessException("系统参数已存在!");
+    } else {
+      this.sysParameterRepository.save(sysParameter);
     }
+  }
 
-    /**
-     * 修改系统参数
-     *
-     * @param sysParameter 系统参数实体
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void update(SysParameter sysParameter) throws BusinessException {
-        if (StrUtil.isEmpty(sysParameter.getSysKey())) {
-            throw new BusinessException("系统参数标识不能为空!");
-        } else {
-            this.sysParameterRepository.save(sysParameter);
-        }
+  /**
+   * 修改系统参数
+   *
+   * @param sysParameter 系统参数实体
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(SysParameter sysParameter) throws BusinessException {
+    if (StrUtil.isEmpty(sysParameter.getSysKey())) {
+      throw new BusinessException("系统参数标识不能为空!");
+    } else {
+      this.sysParameterRepository.save(sysParameter);
     }
+  }
 
-    /**
-     * 删除系统参数
-     *
-     * @param id 主键编号
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
-    public void delete(final Integer id) throws BusinessException {
-        this.sysParameterRepository.deleteById(id);
-    }
+  /**
+   * 删除系统参数
+   *
+   * @param id 主键编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS)
+  public void delete(final Integer id) throws BusinessException {
+    this.sysParameterRepository.deleteById(id);
+  }
 
-    /**
-     * 查询参数
-     *
-     * @param sysParameter 查询条件
-     * @param page         页码
-     * @param size         每页记录数
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Page<SysParameter> get(final SysParameter sysParameter, final Integer page, final Integer size) {
-        ExampleMatcher matcher = ExampleMatcher.matching()
-                .withMatcher("sysKey", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("sysValue", ExampleMatcher.GenericPropertyMatchers.contains())
-                .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
-        Example<SysParameter> example = Example.of(sysParameter, matcher);
-        Pageable pageable = PageRequest.of(page - 1, size);
-        return this.sysParameterRepository.findAll(example, pageable);
-    }
+  /**
+   * 查询参数
+   *
+   * @param sysParameter 查询条件
+   * @param page         页码
+   * @param size         每页记录数
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Page<SysParameter> get(final SysParameter sysParameter, final Integer page, final Integer size) {
+    ExampleMatcher matcher = ExampleMatcher.matching()
+      .withMatcher("sysKey", ExampleMatcher.GenericPropertyMatchers.contains())
+      .withMatcher("sysValue", ExampleMatcher.GenericPropertyMatchers.contains())
+      .withMatcher("describe", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<SysParameter> example = Example.of(sysParameter, matcher);
+    Pageable pageable = PageRequest.of(page - 1, size);
+    return this.sysParameterRepository.findAll(example, pageable);
+  }
 
-    /**
-     * 查询参数值
-     *
-     * @param id 主键编号
-     * @return 参数
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public String getParameter(final Integer id) {
-        Optional<SysParameter> sysParameterOptional = this.sysParameterRepository.findById(id);
-        return sysParameterOptional.map(SysParameter::getSysValue).orElse(null);
-    }
+  /**
+   * 查询参数值
+   *
+   * @param id 主键编号
+   * @return 参数
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public String getParameter(final Integer id) {
+    Optional<SysParameter> sysParameterOptional = this.sysParameterRepository.findById(id);
+    return sysParameterOptional.map(SysParameter::getSysValue).orElse(null);
+  }
 
   /**
    * 根据描述查询告警信息
@@ -131,16 +121,17 @@ public class SysParameterService extends BaseService {
     Pageable pageable = PageRequest.of(page - 1, size);
     return this.sysParameterRepository.findAll(example, pageable);
   }
-    /**
-     * 查询所有参数信息
-     *
-     * @return 通道信息
-     */
-    public List<SysParameter> getAll() {
-      return  sysParameterRepository.findAll();
-    }
+
+  /**
+   * 查询所有参数信息
+   *
+   * @return 通道信息
+   */
+  public List<SysParameter> getAll() {
+    return sysParameterRepository.findAll();
+  }
 
   public List<SysParameter> getAllByStationCode(String stationCode) {
-    return  sysParameterRepository.findAllByStationCode(stationCode);
+    return sysParameterRepository.findAllByStationCode(stationCode);
   }
 }

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

@@ -1,19 +1,16 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.InverterInfo;
 import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipfcst.common.data.repository.WeatherStationInfoRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.*;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -104,10 +101,10 @@ public class WeatherStationInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WeatherStationInfo> get(String stationCode) {
-    List<WeatherStationInfo> resultList = new ArrayList<>();
-    resultList =  this.weatherStationInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WeatherStationInfo> resultList;
+    resultList = this.weatherStationInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WeatherStationInfo::getStationCode)).collect(Collectors.toList());
   }
@@ -134,7 +131,7 @@ public class WeatherStationInfoService extends BaseService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<WeatherStationInfo> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       weatherStationInfoRepository.deleteAll();
       weatherStationInfoRepository.saveAll(beans);
     }

+ 33 - 35
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WeatherStationStatusDataService.java

@@ -1,10 +1,8 @@
 package com.jiayue.ipfcst.console.service;
 
-import com.jiayue.ipfcst.common.data.entity.InverterStatusData;
 import com.jiayue.ipfcst.common.data.entity.WeatherStationStatusData;
 import com.jiayue.ipfcst.common.data.repository.WeatherStationStatusDataRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
-import org.apache.commons.lang.time.DateFormatUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -17,9 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * 环境监测仪数据业务层
@@ -31,12 +27,12 @@ import java.util.stream.Collectors;
 @Service
 public class WeatherStationStatusDataService extends BaseService {
 
-    private final WeatherStationStatusDataRepository weatherStationStatusDataRepository;
+  private final WeatherStationStatusDataRepository weatherStationStatusDataRepository;
 
-    @Autowired
-    public WeatherStationStatusDataService(WeatherStationStatusDataRepository weatherStationStatusDataRepository){
-       this.weatherStationStatusDataRepository = weatherStationStatusDataRepository;
-    }
+  @Autowired
+  public WeatherStationStatusDataService(WeatherStationStatusDataRepository weatherStationStatusDataRepository) {
+    this.weatherStationStatusDataRepository = weatherStationStatusDataRepository;
+  }
 
   /**
    * 分页查询 环境监测仪数据 tl
@@ -47,93 +43,95 @@ public class WeatherStationStatusDataService extends BaseService {
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode,Date startTime, Date endTime,
-                                               Integer page,Integer size,String no) {
+  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode, Date startTime, Date endTime,
+                                                               Integer page, Integer size, String no) {
 
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<WeatherStationStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,no);
+    Specification<WeatherStationStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, no);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page inverterStatusDatas = weatherStationStatusDataRepository.findAll(specification, pageable);
-    List<WeatherStationStatusData> datas = new ArrayList<>();
+    List<WeatherStationStatusData> datas;
     datas = inverterStatusDatas.getContent();
     this.defaultReplace(datas);
     map.put("content", datas);// 结果集
     map.put("count", inverterStatusDatas.getTotalElements());// 总记录数
     return map;
   }
+
   /**
-   *  对集合进行 -99替换null操作
+   * 对集合进行 -99替换null操作
    *
-   * @param datas  需要替换集合
+   * @param datas 需要替换集合
    */
-  public void defaultReplace(List<WeatherStationStatusData> datas){
-    BigDecimal nullBig =  new BigDecimal(-99);
-    for(WeatherStationStatusData w:datas){
+  public void defaultReplace(List<WeatherStationStatusData> datas) {
+    BigDecimal nullBig = new BigDecimal(-99);
+    for (WeatherStationStatusData w : datas) {
 
-      if(w.getDirectR().compareTo(nullBig)==0){
+      if (w.getDirectR().compareTo(nullBig) == 0) {
         w.setDirectR(null);
       }
 
-      if(w.getGlobalR().compareTo(nullBig)==0){
+      if (w.getGlobalR().compareTo(nullBig) == 0) {
         w.setGlobalR(null);
       }
 
-      if(w.getDiffuseR().compareTo(nullBig)==0){
+      if (w.getDiffuseR().compareTo(nullBig) == 0) {
         w.setDiffuseR(null);
       }
 
-      if(w.getObliqueR().compareTo(nullBig)==0){
+      if (w.getObliqueR().compareTo(nullBig) == 0) {
         w.setObliqueR(null);
       }
 
-      if(w.getAirT().compareTo(nullBig)==0){
+      if (w.getAirT().compareTo(nullBig) == 0) {
         w.setAirT(null);
       }
 
-      if(w.getP().compareTo(nullBig)==0){
+      if (w.getP().compareTo(nullBig) == 0) {
         w.setP(null);
       }
 
-      if(w.getRh().compareTo(nullBig)==0){
+      if (w.getRh().compareTo(nullBig) == 0) {
         w.setRh(null);
       }
 
-      if(w.getCellT().compareTo(nullBig)==0){
+      if (w.getCellT().compareTo(nullBig) == 0) {
         w.setCellT(null);
       }
 
-      if(w.getWs().compareTo(nullBig)==0){
+      if (w.getWs().compareTo(nullBig) == 0) {
         w.setWs(null);
       }
 
-      if(w.getWd().compareTo(nullBig)==0){
+      if (w.getWd().compareTo(nullBig) == 0) {
         w.setWd(null);
       }
 
-      if(w.getHourDA().compareTo(nullBig)==0){
+      if (w.getHourDA().compareTo(nullBig) == 0) {
         w.setHourDA(null);
       }
 
-      if(w.getGlobalRDA().compareTo(nullBig)==0){
+      if (w.getGlobalRDA().compareTo(nullBig) == 0) {
         w.setGlobalRDA(null);
       }
 
-      if(w.getDirectRDA().compareTo(nullBig)==0){
+      if (w.getDirectRDA().compareTo(nullBig) == 0) {
         w.setDirectRDA(null);
       }
 
-      if(w.getDiffuseRDA().compareTo(nullBig)==0){
+      if (w.getDiffuseRDA().compareTo(nullBig) == 0) {
         w.setDiffuseRDA(null);
       }
 
-      if(w.getObliqueRDA().compareTo(nullBig)==0){
+      if (w.getObliqueRDA().compareTo(nullBig) == 0) {
         w.setObliqueRDA(null);
       }
 
     }
 
   }
+
   /**
    * 根据时间 分页查询条件 yh
    *
@@ -141,11 +139,11 @@ public class WeatherStationStatusDataService extends BaseService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<WeatherStationStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime,final String no) {
+  Specification<WeatherStationStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String no) {
     return (Specification<WeatherStationStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(no)){
+      if (!"ALL".equals(no)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), no));
       }
       if (startTime != null) {

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

@@ -1,9 +1,7 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
-import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipfcst.common.data.entity.WindTowerInfo;
-import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipfcst.common.data.repository.WindTowerInfoRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import lombok.extern.slf4j.Slf4j;
@@ -14,7 +12,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -94,10 +91,10 @@ public class WindTowerInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WindTowerInfo> get(String stationCode) {
-    List<WindTowerInfo> resultList = new ArrayList<>();
-    resultList =  this.windTowerInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WindTowerInfo> resultList;
+    resultList = this.windTowerInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WindTowerInfo::getStationCode)).collect(Collectors.toList());
   }
@@ -158,7 +155,7 @@ public class WindTowerInfoService extends BaseService {
 
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
   public void saveCloud(List<WindTowerInfo> beans) {
-    if(beans != null && beans.size() > 0){
+    if (beans != null && beans.size() > 0) {
       windTowerInfoRepository.deleteAll();
       windTowerInfoRepository.saveAll(beans);
     }

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

@@ -1,7 +1,6 @@
 package com.jiayue.ipfcst.console.service;
 
 import com.jiayue.ipfcst.common.data.entity.WindTowerStatusData;
-import com.jiayue.ipfcst.common.data.repository.PowerStationStatusDataRepository;
 import com.jiayue.ipfcst.common.data.repository.WindTowerStatusDataRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +12,7 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
+
 import javax.persistence.criteria.Predicate;
 import java.lang.reflect.Field;
 import java.util.*;
@@ -30,8 +30,7 @@ public class WindTowerStatusDataService extends BaseService {
   private final WindTowerStatusDataRepository windTowerStatusDataRepository;
 
   @Autowired
-  public WindTowerStatusDataService(WindTowerStatusDataRepository windTowerStatusDataRepository,
-                                    PowerStationStatusDataRepository powerStationStatusDataRepository) {
+  public WindTowerStatusDataService(WindTowerStatusDataRepository windTowerStatusDataRepository) {
     this.windTowerStatusDataRepository = windTowerStatusDataRepository;
   }
 
@@ -44,20 +43,21 @@ public class WindTowerStatusDataService extends BaseService {
    * @return
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode,Date startTime, Date endTime,
-                                                               Integer page,Integer size,String no) {
+  public Map<String, Object> findByTimeBetweenAndNoAndTimeStep(String stationCode, Date startTime, Date endTime,
+                                                               Integer page, Integer size, String no) {
 
     Map<String, Object> map = new HashMap<>();
     Sort sort = Sort.by(Sort.Direction.DESC, "time");
-    Specification<WindTowerStatusData> specification = this.specificationFindByTime(stationCode,startTime, endTime,no);
+    Specification<WindTowerStatusData> specification = this.specificationFindByTime(stationCode, startTime, endTime, no);
     Pageable pageable = PageRequest.of(page - 1, size, sort); //页码:前端从1开始,jpa从0开始,做个转换
     Page windTowerStatusDatas = windTowerStatusDataRepository.findAll(specification, pageable);
-    List<WindTowerStatusData> datas = new ArrayList<>();
+    List<WindTowerStatusData> datas;
     datas = windTowerStatusDatas.getContent();
     map.put("content", datas);// 结果集
     map.put("count", windTowerStatusDatas.getTotalElements());// 总记录数
     return map;
   }
+
   /**
    * 根据时间 分页查询条件 yh
    *
@@ -65,11 +65,11 @@ public class WindTowerStatusDataService extends BaseService {
    * @param endTime   结束时间
    * @return 过滤条件
    */
-  Specification<WindTowerStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime,final String no) {
+  Specification<WindTowerStatusData> specificationFindByTime(final String stationCode, final Date startTime, final Date endTime, final String no) {
     return (Specification<WindTowerStatusData>) (root, criteriaQuery, cb) -> {
       List<Predicate> predicates = new ArrayList<>();
       predicates.add(cb.equal(root.get("stationCode").as(String.class), stationCode));
-      if (!"ALL".equals(no)){
+      if (!"ALL".equals(no)) {
         predicates.add(cb.equal(root.get("equipmentId").as(String.class), no));
       }
       if (startTime != null) {

+ 107 - 108
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/WindTurbineInfoService.java

@@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
@@ -28,77 +27,77 @@ import java.util.stream.Collectors;
 @Service
 @Slf4j
 public class WindTurbineInfoService extends BaseService {
-    private final WindTurbineInfoRepository windTurbineInfoRepository;
+  private final WindTurbineInfoRepository windTurbineInfoRepository;
 
-    @Autowired
-    public WindTurbineInfoService(WindTurbineInfoRepository windTurbineInfoRepository) {
-        this.windTurbineInfoRepository = windTurbineInfoRepository;
-    }
+  @Autowired
+  public WindTurbineInfoService(WindTurbineInfoRepository windTurbineInfoRepository) {
+    this.windTurbineInfoRepository = windTurbineInfoRepository;
+  }
 
 
-    /**
-     * 新增风机
-     *
-     * @param windTurbine 风机
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void add(WindTurbineInfo windTurbine) throws BusinessException {
-        this.windTurbineInfoRepository.save(windTurbine);
+  /**
+   * 新增风机
+   *
+   * @param windTurbine 风机
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void add(WindTurbineInfo windTurbine) throws BusinessException {
+    this.windTurbineInfoRepository.save(windTurbine);
 //        boolean b = this.windTurbineRepository.existsById(windTurbine.getNo());
 //        if (b) {// 编号已存在
 //            throw new BusinessException("风机编号已存在!");
 //        } else {
 //            this.windTurbineRepository.save(windTurbine);
 //        }
-    }
+  }
 
-    /**
-     * 修改风机
-     *
-     * @param windTurbine 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void update(WindTurbineInfo windTurbine) throws BusinessException {
-        if (StringUtils.isEmpty(windTurbine.getId())) {
-            throw new BusinessException("风机编号不能为空!");
-        } else {
-            this.windTurbineInfoRepository.save(windTurbine);
-        }
+  /**
+   * 修改风机
+   *
+   * @param windTurbine 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void update(WindTurbineInfo windTurbine) throws BusinessException {
+    if (StringUtils.isEmpty(windTurbine.getId())) {
+      throw new BusinessException("风机编号不能为空!");
+    } else {
+      this.windTurbineInfoRepository.save(windTurbine);
     }
+  }
 
-    /**
-     * 删除风机
-     *
-     * @param no 逆变器编号
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.SUPPORTS)
-    public void delete(final Integer no) throws BusinessException {
-        if (StringUtils.isEmpty(no)) {
-            throw new BusinessException("风机编号不能为空!");
-        } else {
-            this.windTurbineInfoRepository.deleteById(no);
-        }
+  /**
+   * 删除风机
+   *
+   * @param no 逆变器编号
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.SUPPORTS)
+  public void delete(final Integer no) throws BusinessException {
+    if (StringUtils.isEmpty(no)) {
+      throw new BusinessException("风机编号不能为空!");
+    } else {
+      this.windTurbineInfoRepository.deleteById(no);
     }
+  }
 
-    /**
-     * 查询风机
-     *
-     * @param no 逆变器编号
-     * @return 逆变器
-     * @throws BusinessException 业务异常
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public WindTurbineInfo get(final Integer no) throws BusinessException {
-        Optional<WindTurbineInfo> optional = this.windTurbineInfoRepository.findById(no);
-        if (optional.isPresent()) {
-            return optional.get();
-        } else {
-            throw new BusinessException("风机不存在!");
-        }
+  /**
+   * 查询风机
+   *
+   * @param no 逆变器编号
+   * @return 逆变器
+   * @throws BusinessException 业务异常
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public WindTurbineInfo get(final Integer no) throws BusinessException {
+    Optional<WindTurbineInfo> optional = this.windTurbineInfoRepository.findById(no);
+    if (optional.isPresent()) {
+      return optional.get();
+    } else {
+      throw new BusinessException("风机不存在!");
     }
+  }
 
   /**
    * 根据场站编号查询风机
@@ -109,71 +108,71 @@ public class WindTurbineInfoService extends BaseService {
    */
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public List<WindTurbineInfo> getByStationCode(String stationCode) {
-    List<WindTurbineInfo> resultList = new ArrayList<>();
-    resultList =  this.windTurbineInfoRepository.findAll();
-    if (!"ALL".equals(stationCode)){
-      resultList = resultList.stream().filter(s->s.getStationCode().equals(stationCode)).collect(Collectors.toList());
+    List<WindTurbineInfo> resultList;
+    resultList = this.windTurbineInfoRepository.findAll();
+    if (!"ALL".equals(stationCode)) {
+      resultList = resultList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
     }
     return resultList.stream().sorted(Comparator.comparing(WindTurbineInfo::getStationCode)).collect(Collectors.toList());
   }
 
-    /**
-     * 查询风机【分页查询】
-     *
-     * @param windTurbine 查询条件
-     * @param page        页码
-     * @param size        每页记录数
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public Page<WindTurbineInfo> get(final WindTurbineInfo windTurbine, final Integer page, final Integer size) {
-        ExampleMatcher matcher =
-                ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains());
-        Example<WindTurbineInfo> example = Example.of(windTurbine, matcher);
-        Sort sort = Sort.by(Sort.Direction.ASC,"stationCode");
-        Pageable pageable = PageRequest.of(page - 1, size,sort);
-        return this.windTurbineInfoRepository.findAll(example, pageable);
-    }
+  /**
+   * 查询风机【分页查询】
+   *
+   * @param windTurbine 查询条件
+   * @param page        页码
+   * @param size        每页记录数
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Page<WindTurbineInfo> get(final WindTurbineInfo windTurbine, final Integer page, final Integer size) {
+    ExampleMatcher matcher =
+      ExampleMatcher.matching().withMatcher("modelNumber", ExampleMatcher.GenericPropertyMatchers.contains());
+    Example<WindTurbineInfo> example = Example.of(windTurbine, matcher);
+    Sort sort = Sort.by(Sort.Direction.ASC, "stationCode");
+    Pageable pageable = PageRequest.of(page - 1, size, sort);
+    return this.windTurbineInfoRepository.findAll(example, pageable);
+  }
 
-    /**
-     * 查询风机
-     *
-     * @return 分页结果
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<WindTurbineInfo> getAll() {
-        return this.windTurbineInfoRepository.findAll();
-    }
+  /**
+   * 查询风机
+   *
+   * @return 分页结果
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WindTurbineInfo> getAll() {
+    return this.windTurbineInfoRepository.findAll();
+  }
 
 
-    /**
-     * 查询所有样板机风机 create by xiuwei
-     *
-     * @return 风机信息
-     */
-    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-    public List<WindTurbineInfo> getAllSample() {
-        WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
-        windTurbineInfo.setSample(true);
-        return windTurbineInfoRepository.findAll(Example.of(windTurbineInfo));
-    }
+  /**
+   * 查询所有样板机风机 create by xiuwei
+   *
+   * @return 风机信息
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public List<WindTurbineInfo> getAllSample() {
+    WindTurbineInfo windTurbineInfo = new WindTurbineInfo();
+    windTurbineInfo.setSample(true);
+    return windTurbineInfoRepository.findAll(Example.of(windTurbineInfo));
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(WindTurbineInfo bean) {
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(WindTurbineInfo bean) {
 //        WindTurbineInfo beanOld = windTurbineInfoRepository.findByName(bean.getName());
 //        if (null != beanOld) {
 //            bean.setId(beanOld.getId());
 //        }
-        windTurbineInfoRepository.save(bean);
-    }
+    windTurbineInfoRepository.save(bean);
+  }
 
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void saveCloud(List<WindTurbineInfo> beans) {
-        if(beans != null && beans.size() > 0){
-            windTurbineInfoRepository.deleteAll();
-            windTurbineInfoRepository.saveAll(beans);
-        }
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+  public void saveCloud(List<WindTurbineInfo> beans) {
+    if (beans != null && beans.size() > 0) {
+      windTurbineInfoRepository.deleteAll();
+      windTurbineInfoRepository.saveAll(beans);
     }
+  }
 
   /**
    * 批量新增逆变器

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.