浏览代码

添加配置文件

chenminghua 2 年之前
父节点
当前提交
d73b29c4e7

+ 4 - 0
web/runeconomy-xk/pom.xml

@@ -26,6 +26,10 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
             <optional>true</optional>

+ 25 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/RunEconomyApplication.java

@@ -1,5 +1,7 @@
 package com.gyee.runeconomy;
 
+import com.gyee.runeconomy.config.GyeeConfig;
+import com.gyee.runeconomy.util.SpringUtils;
 import lombok.extern.log4j.Log4j2;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
@@ -7,6 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.core.env.Environment;
 
+import java.io.File;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
@@ -25,6 +28,8 @@ public class RunEconomyApplication {
         String port = env.getProperty("server.port");
         String path = env.getProperty("server.servlet.context-path");
 
+        createFolder();
+
         log.info("\n-------------------------------------------------------------------\n\t" +
                 "经济运行系统启动成功,访问路径如下:\n\t" +
                 "本地路径: \t\thttp://localhost:" + port + path + "\n\t" +
@@ -37,4 +42,24 @@ public class RunEconomyApplication {
 //        cacheService.initRedisCache();
     }
 
+
+    /**
+     * 功率曲线拟合的数据文件保存路径
+     */
+    private static void createFolder(){
+        GyeeConfig bean = SpringUtils.getBean(GyeeConfig.class);
+        File f1 = new File(bean.getFilePathPrepare());
+        File f2 = new File(bean.getFilePathProcess());
+        File f3 = new File(bean.getFilePathFitting());
+        File f4 = new File(bean.getFilePathDownload());
+        if (!f1.exists())
+            f1.mkdirs();
+        if (!f2.exists())
+            f2.mkdirs();
+        if (!f3.exists())
+            f3.mkdirs();
+        if (!f4.exists())
+            f4.mkdirs();
+    }
+
 }

+ 72 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/config/GyeeConfig.java

@@ -0,0 +1,72 @@
+package com.gyee.runeconomy.config;
+
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.system.ApplicationHome;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "gyee")
+public class GyeeConfig {
+
+    public File jarF = null;
+    {
+        ApplicationHome h = new ApplicationHome(getClass());
+        jarF = h.getSource();
+    }
+
+    /** 数据适配器网址 **/
+    private String adapterUrl;
+    /** 数据准备保存路径(原始数据) **/
+    private String filePathPrepare;
+    /** 数据处理保存路径(处理后的数据) **/
+    private String filePathProcess;
+    /** 数据拟合保存路径(拟合后的数据) **/
+    private String filePathFitting;
+    /** 数据压缩下载 **/
+    private String filePathDownload;
+    /** 功率曲线拟合测点 **/
+    private String points;
+
+    public List<String> getPoints() {
+        return Arrays.asList(this.points.split(","));
+    }
+
+    public String getFilePathPrepare() {
+        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathPrepare;
+    }
+
+    public void setFilePathPrepare(String filePathPrepare) {
+        this.filePathPrepare = filePathPrepare;
+    }
+
+    public String getFilePathProcess() {
+        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathProcess;
+    }
+
+    public void setFilePathProcess(String filePathProcess) {
+        this.filePathProcess = filePathProcess;
+    }
+
+    public String getFilePathFitting() {
+        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathFitting;
+    }
+
+    public void setFilePathFitting(String filePathFitting) {
+        this.filePathFitting = filePathFitting;
+    }
+
+    public String getFilePathDownload() {
+        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathDownload;
+    }
+
+    public void setFilePathDownload(String filePathDownload) {
+        this.filePathDownload = filePathDownload;
+    }
+}

+ 50 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/config/ThreadPoolConfig.java

@@ -0,0 +1,50 @@
+package com.gyee.runeconomy.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+
+@Configuration
+public class ThreadPoolConfig {
+    /**
+     *   默认情况下,在创建了线程池后,线程池中的线程数为0,当有任务来之后,就会创建一个线程去执行任务,
+     *	当线程池中的线程数目达到corePoolSize后,就会把到达的任务放到缓存队列当中;
+     *  当队列满了,就继续创建线程,当线程数量大于等于maxPoolSize后,开始使用拒绝策略拒绝
+     */
+
+    /** 核心线程数(默认线程数) */
+    private static final int corePoolSize = 10;
+    /** 最大线程数 */
+    private static final int maxPoolSize = 20;
+    /** 允许线程空闲时间(单位:默认为秒) */
+    private static final int keepAliveTime = 60;
+    /** 缓冲队列大小 */
+    private static final int queueCapacity = 100;
+    /** 允许等待最长时间 */
+    private static final int awaitTime = 15;
+    /** 线程池名前缀 */
+    private static final String threadNamePrefix = "GYEE-Thread-";
+
+
+    @Bean
+    public ThreadPoolTaskExecutor taskExecutor(){
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(corePoolSize);
+        executor.setMaxPoolSize(maxPoolSize);
+        executor.setQueueCapacity(queueCapacity);
+        executor.setKeepAliveSeconds(keepAliveTime);
+        executor.setThreadNamePrefix(threadNamePrefix);
+        executor.setAwaitTerminationSeconds(awaitTime);
+
+        // 线程池对拒绝任务的处理策略
+        // CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        // 初始化
+        executor.initialize();
+        return executor;
+    }
+
+}

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/config/WebSocketConfig.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.config;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+/**
+ * 开启 WebSocket 支持
+ **/
+@Configuration
+public class WebSocketConfig {
+
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+        System.out.println("开启websocket支持。。。。。");
+        return new ServerEndpointExporter();
+    }
+
+}

+ 1 - 1
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/util/realtimesource/EdosUtil.java

@@ -28,7 +28,7 @@ import java.util.*;
 public class EdosUtil implements IEdosUtil {
 
     private RestTemplate restTemplate =new RestTemplate();
-    @Value("${db.url}")
+    @Value("${gyee.adapter-url}")
     private String baseURL;
 
     @Value("${initialcode}")

+ 19 - 3
web/runeconomy-xk/src/main/resources/application-test.yml

@@ -105,9 +105,25 @@ logging:
     root: info
     com.example: debug
 initialcode: INITIAL
-db:
-  #url: http://127.0.0.1:8011/ts
-  url: http://192.168.11.250:8011/ts
+
 runWindpowerstation: SD_GDDL_RZLX_FDC_STA
 
+gyee:
+  #数据适配器
+  adapter-url: http://127.0.0.1:8011/ts
+  #adapter-url: http://192.168.11.250:8011/ts
+  #数据准备保存路径(原始数据)
+  file-path-prepare: data\prepare\
+  #数据处理保存路径(处理后的数据)
+  file-path-process: data\precess\
+  #数据拟合保存路径(拟合后的数据)
+  file-path-fitting: data\fitting\
+  #下载时数据压缩路径
+  file-path-download: data\zip\
+  #风机实发功率\风机风速\发电机转速\明细状态\风机日发电量\实时欠发状态\风向\对风角度(对风误差)  顺序不能乱
+  points: AI130,AI022,AI128,ZTMX,RFDL,RSSQFZT,AI008,AI036
+
+
+
+
 

+ 15 - 3
web/runeconomy-xk/src/main/resources/application-yun.yml

@@ -105,9 +105,21 @@ logging:
     root: info
     com.example: debug
 initialcode: INITIAL
-db:
-  url: http://127.0.0.1:8011/ts
+
   #url: http://192.168.11.250:8011/ts
 runWindpowerstation: SD_GDDL_RZLX_FDC_STA,SD_GDDL_QDJN_FDC_STA,SD_GDDL_WHWD_FDC_STA,SD_GDDL_WHXQ_FDC_STA,SD_GDDL_RZWL_FDC_STA,SD_GDDL_WFZC_FDC_STA,SD_GDDL_DZXJ_FDC_STA,SD_GDDL_XTTA_FDC_STA,SD_GDDL_BH1_FDC_STA,SD_GDDL_BH2_FDC_STA,SD_GDDL_CG_FDC_STA,SD_GDDL_FJ_FDC_STA,SD_GDDL_YS_FDC_STA,SD_GDDL_FXFC_FDC_STA,SD_GDDL_JNSS_FDC_STA,SD_GDDL_WFBH_FDC_STA,SD_GDDL_PLHS_FDC_STA,SD_GDDL_JNCQ_FDC_STA,SD_GDDL_LXLN_FDC_STA,SD_GDDL_LQJS_FDC_STA,SD_GDDL_ZYXD_FDC_STA,SD_GDDL_ZYFS_FDC_STA
 
-
+gyee:
+  #数据适配器
+  adapter-url: http://127.0.0.1:8011/ts
+  #adapter-url: http://192.168.11.250:8011/ts
+  #数据准备保存路径(原始数据)
+  file-path-prepare: data\prepare\
+  #数据处理保存路径(处理后的数据)
+  file-path-process: data\precess\
+  #数据拟合保存路径(拟合后的数据)
+  file-path-fitting: data\fitting\
+  #下载时数据压缩路径
+  file-path-download: data\zip\
+  #风机实发功率\风机风速\发电机转速\明细状态\风机日发电量\实时欠发状态\风向\对风角度(对风误差)  顺序不能乱
+  points: AI130,AI022,AI128,ZTMX,RFDL,RSSQFZT,AI008,AI036