Browse Source

曲线偏差率分析指标计算调整

王波 4 days ago
parent
commit
482ce60831

+ 5 - 0
generationXK-service/pom.xml

@@ -69,6 +69,11 @@
             <version>1.2.17</version>
             <scope>compile</scope>
         </dependency>
+        <!-- SLF4J Logback 依赖 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-logging</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>io.github.openfeign</groupId>

+ 66 - 62
generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java

@@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -22,6 +24,8 @@ import java.util.concurrent.TimeUnit;
  */
 @SpringBootApplication
 @EnableFeignClients
+@EnableScheduling   // 启用定时任务调度
+@EnableAsync        // 启用异步执行
 @MapperScan({"com.gyee.generation.mapper"})
 public class GenerationMain {
 
@@ -32,68 +36,68 @@ public class GenerationMain {
         System.out.println("启动完成");
 
         //        /*************************风机历史计算服务**************************/
-        Calendar c1 = Calendar.getInstance();
-
-        c1.add(Calendar.DAY_OF_MONTH, -1);
-        ReCalSevice reCalSevice = SpringUtils.getBean("reCalSevice");
-
-        Calendar c = Calendar.getInstance();
-        Logger logger = LoggerFactory.getLogger(GenerationMain.class);
-
-        //        //重算风机
-        reCalSevice.calWt(c.getTime());
-
-                while (true) {
-
-                    Date begin = new Date();
-                    Date end = null;
-                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    logger.info(df.format(c.getTime()).toString());
-
-
-                    EquipmentInfo1Service equipmentInfo1Service = SpringUtils.getBean("equipmentInfo1Service");
-                    EquipmentInfo2Service equipmentInfo2Service = SpringUtils.getBean("equipmentInfo2Service");
-                    EquipmentInfo3Service equipmentInfo3Service = SpringUtils.getBean("equipmentInfo3Service");
-
-
-                    equipmentInfo1Service.calEquipmentInfoDay(begin);
-                    logger.info("equipmentInfo1Service完成一次!。。。。。。");
-                    TimeUnit.SECONDS.sleep(3);
-                    equipmentInfo2Service.calEquipmentInfoDay(begin);
-                    logger.info("equipmentInfo2Service完成一次!。。。。。。");
-                    TimeUnit.SECONDS.sleep(3);
-                    equipmentInfo3Service.calEquipmentInfoDay(begin);
-                    logger.info("equipmentInfo3Service完成一次!。。。。。。");
-                    TimeUnit.SECONDS.sleep(3);
-                    logger.info("equipmentInfo5Service开始!。。。。。。");
-                    EquipmentInfo5Service equipmentInfo5Service = SpringUtils.getBean("equipmentInfo5Service");
-                    TimeUnit.SECONDS.sleep(3);
-                    EquipmentInfo4Service equipmentInfo4Service = SpringUtils.getBean("equipmentInfo4Service");
-                    TimeUnit.SECONDS.sleep(3);
-                    equipmentInfo5Service.calEquipmentInfoDay(begin);
-                    logger.info("equipmentInfo5Service完成一次!。。。。。。");
-                    logger.info("equipmentInfo4Service开始!。。。。。。");
-                    equipmentInfo4Service.calEquipmentInfoDay(begin);
-                    logger.info("equipmentInfo4Service完成一次!。。。。。。");
-
-                    WtAlysisDayService wtAlysisDayService = SpringUtils.getBean("wtAlysisDayService");
-
-                    EquipmentInfoDayTopService equipmentInfoDayTopService = SpringUtils.getBean("equipmentInfoDayTopService");
-                    equipmentInfoDayTopService.calEquipmentInfoDayTop(begin);
-                    equipmentInfoDayTopService.calEquipmentInfoMonthTop(begin);
-                    equipmentInfoDayTopService.calEquipmentInfoYearTop(begin);
-
-                    TimeUnit.SECONDS.sleep(3);
-                    logger.info("wtAlysisyService开始!。。。。。。");
-                    wtAlysisDayService.calEquipmentInfoDay(begin);
-                    logger.info("wtAlysisyService完成!。。。。。。");
-                    end = new Date();
-                    logger.info(df.format(end).toString());
-                    logger.info("完成一次!。。。。。。");
-                    logger.info("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
-
-                    TimeUnit.MINUTES.sleep(15);
-                }
+//        Calendar c1 = Calendar.getInstance();
+//
+//        c1.add(Calendar.DAY_OF_MONTH, -1);
+//        ReCalSevice reCalSevice = SpringUtils.getBean("reCalSevice");
+//
+//        Calendar c = Calendar.getInstance();
+//        Logger logger = LoggerFactory.getLogger(GenerationMain.class);
+//
+//        //        //重算风机
+//        reCalSevice.calWt(c.getTime());
+//
+//                while (true) {
+//
+//                    Date begin = new Date();
+//                    Date end = null;
+//                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//                    logger.info(df.format(c.getTime()).toString());
+//
+//
+//                    EquipmentInfo1Service equipmentInfo1Service = SpringUtils.getBean("equipmentInfo1Service");
+//                    EquipmentInfo2Service equipmentInfo2Service = SpringUtils.getBean("equipmentInfo2Service");
+//                    EquipmentInfo3Service equipmentInfo3Service = SpringUtils.getBean("equipmentInfo3Service");
+//
+//
+//                    equipmentInfo1Service.calEquipmentInfoDay(begin);
+//                    logger.info("equipmentInfo1Service完成一次!。。。。。。");
+//                    TimeUnit.SECONDS.sleep(3);
+//                    equipmentInfo2Service.calEquipmentInfoDay(begin);
+//                    logger.info("equipmentInfo2Service完成一次!。。。。。。");
+//                    TimeUnit.SECONDS.sleep(3);
+//                    equipmentInfo3Service.calEquipmentInfoDay(begin);
+//                    logger.info("equipmentInfo3Service完成一次!。。。。。。");
+//                    TimeUnit.SECONDS.sleep(3);
+//                    logger.info("equipmentInfo5Service开始!。。。。。。");
+//                    EquipmentInfo5Service equipmentInfo5Service = SpringUtils.getBean("equipmentInfo5Service");
+//                    TimeUnit.SECONDS.sleep(3);
+//                    EquipmentInfo4Service equipmentInfo4Service = SpringUtils.getBean("equipmentInfo4Service");
+//                    TimeUnit.SECONDS.sleep(3);
+//                    equipmentInfo5Service.calEquipmentInfoDay(begin);
+//                    logger.info("equipmentInfo5Service完成一次!。。。。。。");
+//                    logger.info("equipmentInfo4Service开始!。。。。。。");
+//                    equipmentInfo4Service.calEquipmentInfoDay(begin);
+//                    logger.info("equipmentInfo4Service完成一次!。。。。。。");
+//
+//                    WtAlysisDayService wtAlysisDayService = SpringUtils.getBean("wtAlysisDayService");
+//
+//                    EquipmentInfoDayTopService equipmentInfoDayTopService = SpringUtils.getBean("equipmentInfoDayTopService");
+//                    equipmentInfoDayTopService.calEquipmentInfoDayTop(begin);
+//                    equipmentInfoDayTopService.calEquipmentInfoMonthTop(begin);
+//                    equipmentInfoDayTopService.calEquipmentInfoYearTop(begin);
+//
+//                    TimeUnit.SECONDS.sleep(3);
+//                    logger.info("wtAlysisyService开始!。。。。。。");
+//                    wtAlysisDayService.calEquipmentInfoDay(begin);
+//                    logger.info("wtAlysisyService完成!。。。。。。");
+//                    end = new Date();
+//                    logger.info(df.format(end).toString());
+//                    logger.info("完成一次!。。。。。。");
+//                    logger.info("执行用时" + com.gyee.generation.util.DateUtils.secondsDiff(begin, end) + "秒");
+//
+//                    TimeUnit.MINUTES.sleep(15);
+//                }
         //
         //        /*************************风机历史计算服务**************************/
         //

+ 114 - 11
generationXK-service/src/main/java/com/gyee/generation/task/AnalysisTask.java

@@ -1,24 +1,127 @@
 package com.gyee.generation.task;
 
-import com.gyee.generation.service.PowerCurveFittingByTimeService;
+import com.gyee.generation.service.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import java.util.Date;
 
 @Component
 public class AnalysisTask {
-    @Resource
+    private static final Logger logger = LoggerFactory.getLogger(AnalysisTask.class);
+
+    @Autowired
     private PowerCurveFittingByTimeService powerCurveFittingByTimeService;
+    @Autowired
+    private InputOrOutPutService inputOrOutPutService;
+    @Autowired
+    private WindturbineGoodnessService windturbineGoodnessService;
+    @Autowired
+    private EquipmentInfo3Service equipmentInfo3Service;
+    @Autowired
+    private EquipmentInfo2Service equipmentInfo2Service;
+    @Autowired
+    private EquipmentInfo4Service equipmentInfo4Service;
+
+    // 每日1点 - 日曲线偏差
+    @Async
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void rqxpc() {
+        try {
+            logger.info("日曲线偏差开始运行");
+
+            Date date = new Date();
+            powerCurveFittingByTimeService.cureFittingDay(date, "NX_FGS_HA_FDC_STA");
+            logger.info("日曲线偏差运行完成");
+        } catch (Exception e) {
+            logger.error("日曲线偏差运行失败", e);
+        }
+    }
+
+    // 每日1点10分 - 月曲线偏差
+    @Async
+    @Scheduled(cron = "0 10 1 * * ?")
+    public void yqxpc() {
+        try {
+            logger.info("月曲线偏差开始运行");
+            Date date = new Date();
+            powerCurveFittingByTimeService.cureFittingMonth(date, "0", null);
+            logger.info("月曲线偏差运行完成");
+        } catch (Exception e) {
+            logger.error("月曲线偏差运行失败", e);
+        }
+    }
+
+    // 每5分钟 - 切入切出状态切换记录
+    @Async
+    @Scheduled(cron = "0 0/5 * * * ?")
+    public void qrqc() {
+        try {
+            logger.info("切入切出状态切换记录调度程序执行开始");
+            inputOrOutPutService.inputOrOutputSpeed(new Date());
+            logger.info("切入切出状态切换记录调度任务处理完成");
+        } catch (Exception e) {
+            logger.error("切入切出状态切换记录调度任务执行失败", e);
+        }
+    }
+
+    // 每日2点 - 功率一致性系数和拟合优度统计
+    @Async
+    @Scheduled(cron = "0 0 2 * * ?")
+    public void glyzx() {
+        try {
+            logger.info("功率一致性系数和拟合优度统计调度程序执行开始");
+            windturbineGoodnessService.calWindturbineGoodness(new Date());
+            logger.info("功率一致性系数和拟合优度统计调度任务处理完成");
+        } catch (Exception e) {
+            logger.error("功率一致性系数和拟合优度统计调度任务执行失败", e);
+        }
+    }
+
+    // 每15分钟 - 设备指标2
+    @Async
+    @Scheduled(cron = "0 0/15 * * * ?")
+    public void sbzb2() {
+        try {
+            logger.info("设备指标2调度程序执行开始");
+            Date date = new Date();
+            equipmentInfo2Service.calEquipmentInfoDay(date);
+            logger.info("设备指标2调度程序执行完成");
+        } catch (Exception e) {
+            logger.error("设备指标2调度任务执行失败", e);
+        }
+    }
+
+    // 每15分钟 - 设备指标3
+    @Async
+    @Scheduled(cron = "0 0/15 * * * ?")
+    public void sbzb3() {
+        try {
+            logger.info("设备指标3调度程序执行开始");
+            Date date = new Date();
+            equipmentInfo3Service.calEquipmentInfoDay(date);
+            logger.info("设备指标3调度程序执行完成");
+        } catch (Exception e) {
+            logger.error("设备指标3调度任务执行失败", e);
+        }
+    }
 
-    //每日0点02-月曲线偏差
-    @Scheduled(cron = "0 02 0 * * ?")
-    public void yqxpc() throws Exception {
-        Date date=new Date();
-        powerCurveFittingByTimeService.cureFittingDay(date, "NX_FGS_HA_FDC_STA");
-        powerCurveFittingByTimeService.cureFittingMonth(date,"0",null);
-        powerCurveFittingByTimeService.cureFittingYear(date, "NX_FGS_HA_FDC_STA");
-        System.out.println("月曲线偏差运行完成");
+    // 每15分钟 - 设备指标4
+    @Async
+    @Scheduled(cron = "0 0/15 * * * ?")
+    public void sbzb4() {
+        try {
+            logger.info("设备指标4调度程序执行开始");
+            Date date = new Date();
+            equipmentInfo4Service.calEquipmentInfoDay(date);
+            logger.info("设备指标4调度程序执行完成");
+        } catch (Exception e) {
+            logger.error("设备指标4调度任务执行失败", e);
+        }
     }
 }