Просмотр исходного кода

历史计算服务修正优化

shilin 2 лет назад
Родитель
Сommit
39f9b3cade
28 измененных файлов с 3362 добавлено и 1619 удалено
  1. 15 16
      realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java
  2. 70 69
      realtime/generationXK-service/src/main/java/com/gyee/generation/config/XxlJobConfig.java
  3. 36 32
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/CoefficientService.java
  4. 26 32
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/GoodnessOfFitService.java
  5. 17 106
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/InputOrOutPutService.java
  6. 48 867
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/LimitEventnewService.java
  7. 157 107
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeGfService.java
  8. 9 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeService.java
  9. 28 248
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java
  10. 3 6
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/TimelinessRateService.java
  11. 23 84
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java
  12. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtwindDayInfoService.java
  13. 101 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/BrownoutsThread.java
  14. 549 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/BrownoutsThreadPool.java
  15. 75 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/GoodnessOfFitThread.java
  16. 163 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/GoodnessOfFitThreadPool.java
  17. 191 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/InputOrOutPutThreadPool.java
  18. 58 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/InputOrOutPutkThread.java
  19. 84 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/MainBrownoutsThread.java
  20. 534 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/MainBrownoutsThreadPool.java
  21. 54 46
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/SaticSchedulePgTask.java
  22. 98 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/ShutdownnewThread.java
  23. 667 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/ShutdownnewThreadPool.java
  24. 133 0
      realtime/generationXK-service/src/main/resources/application-jn.yml
  25. 1 1
      realtime/generationXK-service/src/main/resources/application.yml
  26. 3 3
      realtime/generationXK-service/src/main/resources/xxl-job-executor.properties
  27. 21 0
      realtime/generationXK-service/src/main/resources/xxl-job-executorJN.properties
  28. 197 0
      realtime/generationXK-service/src/test/java/com/gyee/generation/HealthTest.java

+ 15 - 16
realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java

@@ -1,14 +1,9 @@
 package com.gyee.generation;
 
-import com.gyee.generation.service.PowerCurveFittingByTimeService;
-import com.gyee.generation.util.SpringUtils;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
-import java.util.Calendar;
-import java.util.Date;
-
 /**
  * @ClassName : GenerationMain
  * @Author : xieshengjie
@@ -20,13 +15,17 @@ import java.util.Date;
 public class GenerationMain {
     public static void main(String[] args) throws Exception {
         SpringApplication.run(GenerationMain.class, args);
-
-
-
+//
+//
+//
 //        CacheService cacheService= SpringUtils.getBean("cacheService");
 //        cacheService.initRedisCache();
 //
 //
+//        Calendar c=Calendar.getInstance();
+//        //故障转换率记录调度程序执行开始!
+//        TimelinessRateService timelinessRateService= SpringUtils.getBean("timelinessRateService");
+//        timelinessRateService.failRate(c.getTime());
 
 //        ProEconEqOriginalService proEconEqOriginalService= SpringUtils.getBean("proEconEqOriginalService");
 //        System.out.println("开始生成风机报表指标统计。。。。。。");
@@ -71,14 +70,14 @@ public class GenerationMain {
 //        initialPointGoldenXkByEqEdosService.initalQx();
 //        System.out.println("结束导出气象测点表。。。。。。");
 //
-        PowerCurveFittingByTimeService powerCurveFittingByTimeService= SpringUtils.getBean("powerCurveFittingByTimeService");
-        Calendar c=Calendar.getInstance();
-//        c.set(Calendar.MONTH,7);
-//        c.set(Calendar.DAY_OF_MONTH,2);
-        Date date =c.getTime();
-
-        powerCurveFittingByTimeService.cureFittingMonth(date,"1");
-        powerCurveFittingByTimeService.cureFittingYear(date);
+//        PowerCurveFittingByTimeService powerCurveFittingByTimeService= SpringUtils.getBean("powerCurveFittingByTimeService");
+//        Calendar c=Calendar.getInstance();
+////        c.set(Calendar.MONTH,7);
+////        c.set(Calendar.DAY_OF_MONTH,2);
+//        Date date =c.getTime();
+//
+//        powerCurveFittingByTimeService.cureFittingMonth(date,"1");
+//        powerCurveFittingByTimeService.cureFittingYear(date);
 //        CacheService cacheService= SpringUtils.getBean("cacheService");
 //        cacheService.initRedisCache();
 //        InputOrOutPutService inputOrOutPutService= SpringUtils.getBean("inputOrOutPutService");

+ 70 - 69
realtime/generationXK-service/src/main/java/com/gyee/generation/config/XxlJobConfig.java

@@ -1,70 +1,71 @@
-//package com.gyee.generation.config;
-//
-//
-//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.context.EnvironmentAware;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.context.annotation.PropertySource;
-//import org.springframework.core.env.Environment;
-//
-///**
-// * xxl-job config
-// *
-// * @author xuxueli 2017-04-28
-// */
-//
-//
-//@Configuration
-////@PropertySource("classpath:xxl-job-executor.properties")
-////@PropertySource("classpath:xxl-job-executorWPLY.properties")
+package com.gyee.generation.config;
+
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
+
+/**
+ * xxl-job config
+ *
+ * @author xuxueli 2017-04-28
+ */
+
+
+@Configuration
+@PropertySource("classpath:xxl-job-executor.properties")
+//@PropertySource("classpath:xxl-job-executorWPLY.properties")
 //@PropertySource("classpath:xxl-job-executorRG.properties")
-//public class XxlJobConfig implements EnvironmentAware {
-//    private Environment env;
-//
-//
-//    @Override
-//    public void setEnvironment(Environment environment) {
-//        this.env=environment;
-//    }
-//
-//    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
-//
-//
-//
-//    @Bean
-//    public XxlJobSpringExecutor xxlJobExecutor() {
-//        logger.info(">>>>>>>>>>> xxl-job config init.");
-//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-//        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
-//        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
-//        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
-//        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
-//        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
-//        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
-//        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
-//        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
-//        return xxlJobSpringExecutor;
-//    }
-//
-//    /**
-//     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
-//     *
-//     *      1、引入依赖:
-//     *          <dependency>
-//     *             <groupId>org.springframework.cloud</groupId>
-//     *             <artifactId>spring-cloud-commons</artifactId>
-//     *             <version>${version}</version>
-//     *         </dependency>
-//     *
-//     *      2、配置文件,或者容器启动变量
-//     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
-//     *
-//     *      3、获取IP
-//     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
-//     */
-//
-//
-//}
+//@PropertySource("classpath:xxl-job-executorJN.properties")
+public class XxlJobConfig implements EnvironmentAware {
+    private Environment env;
+
+
+    @Override
+    public void setEnvironment(Environment environment) {
+        this.env=environment;
+    }
+
+    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+
+
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        logger.info(">>>>>>>>>>> xxl-job config init.");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(env.getProperty("xxl.job.admin.addresses"));
+        xxlJobSpringExecutor.setAppname(env.getProperty("xxl.job.executor.appname"));
+        xxlJobSpringExecutor.setAddress(env.getProperty("xxl.job.executor.address"));
+        xxlJobSpringExecutor.setIp(env.getProperty("xxl.job.executor.ip"));
+        xxlJobSpringExecutor.setPort(Integer.parseInt(env.getProperty("xxl.job.executor.port")));
+        xxlJobSpringExecutor.setAccessToken(env.getProperty("xxl.job.accessToken"));
+        xxlJobSpringExecutor.setLogPath(env.getProperty("xxl.job.executor.logpath"));
+        xxlJobSpringExecutor.setLogRetentionDays(Integer.parseInt(env.getProperty("xxl.job.executor.logretentiondays")));
+        return xxlJobSpringExecutor;
+    }
+
+    /**
+     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+     *
+     *      1、引入依赖:
+     *          <dependency>
+     *             <groupId>org.springframework.cloud</groupId>
+     *             <artifactId>spring-cloud-commons</artifactId>
+     *             <version>${version}</version>
+     *         </dependency>
+     *
+     *      2、配置文件,或者容器启动变量
+     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+     *
+     *      3、获取IP
+     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+     */
+
+
+}

+ 36 - 32
realtime/generationXK-service/src/main/java/com/gyee/generation/service/CoefficientService.java

@@ -1,10 +1,12 @@
 package com.gyee.generation.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
 import com.gyee.generation.init.CacheContext;
-import com.gyee.generation.model.auto.*;
+import com.gyee.generation.model.auto.ProBasicEquipment;
+import com.gyee.generation.model.auto.ProBasicEquipmentPoint;
+import com.gyee.generation.model.auto.ProEconActivePowerData;
+import com.gyee.generation.model.auto.ProEconWtPowerCurveFitting;
 import com.gyee.generation.model.vo.StatData;
 import com.gyee.generation.model.vo.WpType;
 import com.gyee.generation.service.auto.IProEconWtPowerCurveFittingService;
@@ -199,17 +201,22 @@ public class CoefficientService {
 
         if (dataList != null && dataList.size() != 0) {
 
-            List<ProEconWtPowerCurveFitting> powerList;
+
 
             Calendar c = Calendar.getInstance();
             c.setTime(currentDate);
 
-            QueryWrapper<ProEconWtPowerCurveFitting> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("windturbine_id",windturbineId);
-            powerList = proEconWtPowerCurveFittingService.list(queryWrapper);
-//                    .stream()
-//                    .filter(i -> i.getWindturbineId().equals(windturbineId)).collect(Collectors.toList());
+//            QueryWrapper<ProEconWtPowerCurveFitting> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("windturbine_id",windturbineId);
+//            powerList = proEconWtPowerCurveFittingService.list(queryWrapper);
+
 
+            Map<Double,ProEconWtPowerCurveFitting> curveFittingPowerMap=null;
+            if(CacheContext.curveFittingPowerMap.containsKey(windturbineId))
+            {
+                curveFittingPowerMap=CacheContext.curveFittingPowerMap.get(windturbineId);
+
+            }
 
             for (ProEconActivePowerData data : dataList) {
                 Double p1 = data.getPower();
@@ -247,37 +254,34 @@ public class CoefficientService {
                             }
                         }
                     } else {
-                        if (powerList.size() > 0) {
-                            Double finalSpeed = speed;
-                            OptionalDouble opd = powerList.stream().filter(i -> Objects.equals(i.getSpeed(), finalSpeed)).mapToDouble(ProEconWtPowerCurveFitting::getOptimalPower).findFirst();
+                        if (null!=curveFittingPowerMap && curveFittingPowerMap.containsKey(speed)) {
+                            double optimalPower=curveFittingPowerMap.get(speed).getOptimalPower();
 
-
-                            double p;
-                            if (opd.isPresent()) {
-                                p = opd.getAsDouble();
-                                if (p != 0) {
-                                    for (int i = 0; i < data.getFrequency(); i++) {
-                                        result += Math.abs((p - p1) / p);
-                                        count += 1;
-                                    }
+                            if (optimalPower != 0) {
+                                for (int i = 0; i < data.getFrequency(); i++) {
+                                    result += Math.abs((optimalPower - p1) / optimalPower);
+                                    count += 1;
                                 }
-                            } else {
+                            }
+
+                        }else {
+
 
-                                DoubleSummaryStatistics summaryStatistics = powerList.stream().mapToDouble(ProEconWtPowerCurveFitting::getSpeed).summaryStatistics();
+                            DoubleSummaryStatistics summaryStatistics = curveFittingPowerMap.entrySet()
+                                    .stream()
+                                    .collect(Collectors.summarizingDouble(Map.Entry::getKey));
+                            double max = summaryStatistics.getMax();
+                            if (speed > max) {
 
-                                double max = summaryStatistics.getMax();
-                                if (speed > max) {
-                                    summaryStatistics = powerList.stream().mapToDouble(ProEconWtPowerCurveFitting::getActualPower).summaryStatistics();
-                                    p = summaryStatistics.getMax();
-                                    if (p != 0.0) {
+                                double actualPower=curveFittingPowerMap.get(speed).getActualPower();
 
-                                        for (int i = 0; i < data.getFrequency(); i++) {
-                                            result += Math.abs((p - p1) / p);
-                                            count += 1;
-                                        }
+                                if (actualPower != 0.0) {
+
+                                    for (int i = 0; i < data.getFrequency(); i++) {
+                                        result += Math.abs((actualPower - p1) / actualPower);
+                                        count += 1;
                                     }
                                 }
-
                             }
 
                         }

+ 26 - 32
realtime/generationXK-service/src/main/java/com/gyee/generation/service/GoodnessOfFitService.java

@@ -1,13 +1,15 @@
 package com.gyee.generation.service;
 
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
 import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.model.auto.ProBasicEquipment;
 import com.gyee.generation.model.auto.ProBasicEquipmentPoint;
 import com.gyee.generation.model.auto.ProEconWtCurveFittingMonth;
+import com.gyee.generation.model.vo.CurveType;
 import com.gyee.generation.model.vo.FitClassVo;
 import com.gyee.generation.model.vo.StatData;
 import com.gyee.generation.model.vo.WpType;
@@ -15,10 +17,12 @@ import com.gyee.generation.service.auto.IProEconWtCurveFittingMonthService;
 import com.gyee.generation.util.DateUtils;
 import com.gyee.generation.util.StringUtils;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
+import com.gyee.generation.util.redis.RedisService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.Executor;
 
 @Service
 public class GoodnessOfFitService {
@@ -29,6 +33,11 @@ public class GoodnessOfFitService {
     private IEdosUtil edosUtil;
     @Resource
     private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
+    @Resource
+    private RedisService redisService;
+
+    @Resource
+    private Executor executor;
 
     public Map<String,Map<String,Double>> goodnessOfFit(String wtId,Date nowDate) throws Exception {
 
@@ -57,17 +66,22 @@ public class GoodnessOfFitService {
 
         List<FitClassVo> theList = new ArrayList<>();
 
-        List<ProEconWtCurveFittingMonth> powerList;
-        QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("year",year).eq("month",month).eq("windturbine_id",wtId);
-        powerList = proEconWtCurveFittingMonthService.list(queryWrapper);
-//                    .stream().filter(i->i.getMonth().equals(month)
-//                && i.getWindturbineId().equals(wtId)
-//                && i.getYear().equals(year)).collect(Collectors.toList());
+        List<ProEconWtCurveFittingMonth> powerList=new ArrayList<>();
+
+
+
+        if (redisService.hasKey(CurveType.monthCurve.id+"_"+wtId)){
+            String cp0String = redisService.get(CurveType.monthCurve.id+"_"+wtId);
+            powerList = JSONObject.parseObject(cp0String, new TypeReference< List<ProEconWtCurveFittingMonth>>() {
+            });
+        }else
+        {
+//            QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("year",year).eq("month",month).eq("windturbine_id",wtId);
+//            powerList = proEconWtCurveFittingMonthService.list(queryWrapper);
+        }
         ProBasicEquipment wt=CacheContext.wtmap.get(wtId);
-//            for (ProBasicEquipment wt : CacheContext.wtls)
-//
-//            {
+
 
         List<FitClassVo> fitsD= new ArrayList<>();
         List<FitClassVo> fitsM= new ArrayList<>();
@@ -189,27 +203,7 @@ public class GoodnessOfFitService {
             }
 
         });
-//            }
-
-
-//
-//            for (FitClassVo item : theList)
-//            {
-//                Double rnew = 0.0;
-//                Double speed = 0.0;
-//
-//                if (item.getEpower() != 0)
-//                {
-//                    rnew = (Double)Math.sqrt((double)(item.getPower() / item.getEpower()));
-//                }
-//                if (item.getNumber() != 0)
-//                {
-//                    speed = item.getSpeed() / item.getNumber();
-//                }
-//                item.setSpeed(speed);
-//                item.setPower(rnew);
-//
-//            }
+
 
         return resultmap;
     }

+ 17 - 106
realtime/generationXK-service/src/main/java/com/gyee/generation/service/InputOrOutPutService.java

@@ -1,14 +1,13 @@
 package com.gyee.generation.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.gyee.common.contant.ContantXk;
-import com.gyee.common.model.PointData;
 import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.model.auto.*;
 import com.gyee.generation.model.vo.WpType;
 import com.gyee.generation.service.auto.IProEconInOrOutSpeedTotal2Service;
 import com.gyee.generation.service.auto.IProEconInOrOutSpeedTotalService;
 import com.gyee.generation.service.auto.IProEconInputOrOutputSpeedService;
+import com.gyee.generation.task.InputOrOutPutkThread;
 import com.gyee.generation.util.DateUtils;
 import com.gyee.generation.util.StringUtils;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
@@ -19,6 +18,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
+import java.util.concurrent.Executor;
 import java.util.stream.Collectors;
 
 @Service
@@ -33,130 +33,41 @@ public class InputOrOutPutService {
     @Resource
     private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
 
+    @Resource
+    private Executor executor;
     @Value("${frequency.cutinandout}")
     private Integer frequency;
 
-    private static Map<String,Double> wtLastStatusMap=new HashMap<>();
 
-    private static  Map<String,ProEconInputOrOutputSpeed> wtTimeStatusMap=new HashMap<>();
 
     public void inputOrOutputSpeed(Date recordDate) throws Exception {
 
         Date begin = DateUtils.addMinutes(recordDate, -frequency);
-        Date daybegin = DateUtils.addMinutes(recordDate, -frequency*2);
-
+//
+//        Date begin = DateUtils.addSeconds(recordDate, -frequency);
         Date end = recordDate;
-        for(ProBasicEquipment wt:CacheContext.wtls)
-        {
-            if(wt.getWindpowerstationId().contains(WpType.GDC.id))
-            {
-                continue;
-            }
-
-            Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getNemCode());
 
-            QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
-            queryWrapper.ge("record_date",daybegin).le("record_date",end).eq("windturbine_id",wt.getId());
-            List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
-//            .stream()
-//                    .filter(i -> i.getWindturbineId().equals(wt.getId())
-//                            && (i.getRecordDate().compareTo(daybegin) == 0 || i.getRecordDate().after(daybegin))
-//                            && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
-//                           ).collect(Collectors.toList());
 
-            if(!recordList.isEmpty())
+        for (int i = 0; i < CacheContext.wtls.size(); i++) {
             {
-                for(ProEconInputOrOutputSpeed po:recordList)
-                {
-                    wtTimeStatusMap.put(String.valueOf(po.getRecordDate().getTime()),po);
+                ProBasicEquipment wt = CacheContext.wtls.get(i);
+                if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
+                    continue;
                 }
-            }
-
-            double lastStatus=-1;
-
-
-            ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.MXZT);
-            ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
-
-            //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
-            List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxzt.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
-            List<PointData> ssfsls = edosUtil.getHistoryDatasSnap(ssfs.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
-
-            if(!statusls.isEmpty() && !ssfsls.isEmpty() && ssfsls.size()==statusls.size())
-            {
-                for(int i=0;i<statusls.size();i++)
-                {
+//
+//                try {
+//                    Thread.sleep(100);
+//                } catch (InterruptedException e1) {
+//                    e1.printStackTrace();
+//                }
+                new Thread(new InputOrOutPutkThread(executor,  wt,  begin, end,proEconInputOrOutputSpeedService, edosUtil)).start();
 
-
-                    if(wtLastStatusMap.containsKey(wt.getId()))
-                    {
-                        lastStatus=wtLastStatusMap.get(wt.getId());
-                    }
-
-                    PointData statuspo=statusls.get(i);
-                    PointData ssfspo=ssfsls.get(i);
-                    double status=StringUtils.round(statuspo.getPointValueInDouble(),0);
-
-                    if(i==0)
-                    {
-                        lastStatus=status;
-                    }
-                    if (!Objects.equals(lastStatus, status))
-                    {
-
-                        //     切入切出风速
-                        if (lastStatus == 0 && status == 2)
-                        {
-                            ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
-
-                            input.setWindturbineId(wt.getId());
-                            input.setWindpowerstationId(wt.getWindpowerstationId());
-                            input.setProjectId(wt.getProjectId());
-                            input.setLineId(wt.getLineId());
-                            input.setRecordDate(DateUtils.truncate(new Date(statuspo.getPointTime())));
-                            input.setInputOrOutput(1);
-
-
-                            input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
-
-                            if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())))
-                            {
-                                proEconInputOrOutputSpeedService.save(input);
-                            }
-                            lastStatus=status;
-
-                        }
-                        else if (lastStatus == 2 && status== 0)
-                        {
-                            ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
-                            input.setWindturbineId(wt.getId());
-                            input.setWindpowerstationId(wt.getWindpowerstationId());
-                            input.setProjectId(wt.getProjectId());
-                            input.setLineId(wt.getLineId());
-                            input.setRecordDate(DateUtils.truncate(new Date(statuspo.getPointTime())));
-                            input.setInputOrOutput(0);
-
-                            input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
-
-                            if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())))
-                            {
-                                proEconInputOrOutputSpeedService.save(input);
-                            }
-                            lastStatus=status;
-                        }
-
-                        wtLastStatusMap.put(wt.getId(), status);
-
-                    }
-                }
             }
 
         }
 
     }
 
-
-
     public void inputOrOutput(Date currentDate) {
         currentDate = DateUtils.truncate(currentDate);
 //        Date end = DateUtils.addDays(currentDate, 1);

+ 48 - 867
realtime/generationXK-service/src/main/java/com/gyee/generation/service/LimitEventnewService.java

@@ -1,17 +1,16 @@
 package com.gyee.generation.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.gyee.common.contant.ContantXk;
 import com.gyee.common.model.PointData;
 import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.model.auto.*;
-import com.gyee.generation.model.vo.StatData;
 import com.gyee.generation.service.auto.IProEconBrownoutsEvent2Service;
 import com.gyee.generation.service.auto.IProEconBrownoutsEventService;
 import com.gyee.generation.service.auto.IProEconMainBrownouts2Service;
 import com.gyee.generation.service.auto.IProEconMainBrownoutsService;
+import com.gyee.generation.task.BrownoutsThread;
+import com.gyee.generation.task.MainBrownoutsThread;
 import com.gyee.generation.util.DateUtils;
-import com.gyee.generation.util.StringUtils;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -20,6 +19,8 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
 import java.util.stream.Collectors;
 
 @Service
@@ -42,6 +43,11 @@ public class LimitEventnewService {
     @Resource
     private IEdosUtil edosUtil;
 
+    @Resource
+    private Executor executor;
+    @Resource
+    private Executor mainexecutor;
+
     @Value("${frequency.powerrationing}")
     private Integer frequency;
     public static Logger logger = LoggerFactory.getLogger(ShutdownnewService.class);
@@ -87,34 +93,34 @@ public class LimitEventnewService {
         statusDescriptionMap.put(13, "设备离线");
 
         for (ProBasicPowerstation wp : CacheContext.wpls) {
-            Map<String, ProBasicPowerstationPoint> wppointmap = CacheContext.wppointmap.get(wp.getId());
-
-            //取实时状态数据 赋值给status
-
-            if (wppointmap.containsKey(ContantXk.CZZT)) {
-                ProBasicPowerstationPoint mxztPoint = wppointmap.get(ContantXk.CZZT);
-                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
-                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000, null, 1L);
-                wpstatusMap.put(wp.getId(), statusls);
-            }
-
+//            Map<String, ProBasicPowerstationPoint> wppointmap = CacheContext.wppointmap.get(wp.getId());
+//
+//            //取实时状态数据 赋值给status
+//
+//            if (wppointmap.containsKey(ContantXk.CZZT)) {
+//                ProBasicPowerstationPoint mxztPoint = wppointmap.get(ContantXk.CZZT);
+//                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+//                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000, null, 1L);
+//                wpstatusMap.put(wp.getId(), statusls);
+//            }
+            wpstatusMap.put(wp.getId(), null);
             //初始化将所有风场编号作为key,value全部赋值为null
             oldMainBrownoutsMap.put(wp.getId(), null);
             oldMainBrownouts2Map.put(wp.getId(), null);
 
         }
         for (ProBasicEquipment wt : CacheContext.wtls) {
-            Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
-
-            //取实时状态数据 赋值给status
-
-            if (windturbinetestingpointnewMap.containsKey(ContantXk.MXZT)) {
-                ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
-                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
-                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000, null, 1L);
-                statusMap.put(wt.getId(), statusls);
-            }
-
+//            Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
+//
+//            //取实时状态数据 赋值给status
+//
+//            if (windturbinetestingpointnewMap.containsKey(ContantXk.MXZT)) {
+//                ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
+//                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+//                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000, null, 1L);
+//                statusMap.put(wt.getId(), statusls);
+//            }
+            statusMap.put(wt.getId(), null);
             //初始化将所有风机编号作为key,value全部赋值为null
             oldBrownoutsStatusMap.put(wt.getId(), null);
             oldBrownoutsStatus2Map.put(wt.getId(), null);
@@ -169,263 +175,35 @@ public class LimitEventnewService {
             }
         }
 //*************************主表数据计算*****************************************************************************/
-        //遍历PG数据库中存在的记录,恢复时间为空的集合
-        for (String wpId : oldMainBrownoutsMap.keySet()) {
-            ProEconMainBrownouts mainBrownouts = null;
-            ProEconMainBrownouts2 mainBrownouts2;
-            //获取5分钟的状态值
-            List<PointData> statusls = wpstatusMap.get(wpId);
-
-            Map<String, ProBasicPowerstationPoint> wppointmap = CacheContext.wppointmap.get(wpId);
-            //记录上次判定的状态值
-            int lastStatus = (int) statusls.get(0).getPointValueInDouble();
-            for (PointData stpo : statusls) {
-
-                //获取当前状态
-                int currentStatus = (int) stpo.getPointValueInDouble();
-                //获取当前时间
-                Date currentTime = new Date(stpo.getPointTime());
-                //如果数据库中不存在该风机未完成的故障记录,进入
-                if (mainBrownouts == null) {
-                    if (currentStatus == 4) {
-                        mainBrownouts = new ProEconMainBrownouts();
-
-                        intialainBrownouts(wpId, wppointmap, currentTime, mainBrownouts);
-
-                        oldMainBrownoutsMap.put(wpId, mainBrownouts);
-
-
-                        mainBrownouts2 = new ProEconMainBrownouts2();
-                        intialainBrownouts2(wpId, wppointmap, currentTime, mainBrownouts2);
-                        oldMainBrownouts2Map.put(wpId, mainBrownouts2);
-                    }
-
-
-                    //将当前状态赋值给过去状态
-                    lastStatus = currentStatus;
-                } else if (lastStatus != currentStatus) {
-
-                    //如果添加了状态值,状态值变化存储,并清空
-                    if (oldMainBrownoutsMap.containsKey(wpId)) {
-
-                        //获取数据库中的状态值,状态值变化存储,并清空
-                        mainBrownouts = oldMainBrownoutsMap.get(wpId);
-                        if (mainBrownouts == null) {
-                            mainBrownouts = new ProEconMainBrownouts();
-                            intialainBrownouts(wpId, wppointmap, currentTime, mainBrownouts);
-                            oldMainBrownoutsMap.put(wpId, mainBrownouts);
-
-                        } else {
-                            finishMainBrownouts(wpId, mainBrownouts, currentTime);
-                            oldMainBrownoutsMap.put(wpId, null);
-                            mainBrownouts = null;
-                        }
-
-
-                    }
-
-                    if (oldMainBrownouts2Map.containsKey(wpId)) {
-
-                        //获取数据库中的状态值,状态值变化存储,并清空
-                        mainBrownouts2 = oldMainBrownouts2Map.get(wpId);
-                        if (mainBrownouts2 == null) {
-                            mainBrownouts2 = new ProEconMainBrownouts2();
-                            intialainBrownouts2(wpId, wppointmap, currentTime, mainBrownouts2);
-                            oldMainBrownouts2Map.put(wpId, mainBrownouts2);
-                        } else {
-                            finishMainBrownouts2(wpId, mainBrownouts2, currentTime);
-                            oldMainBrownouts2Map.put(wpId, null);
-                        }
-
 
-                    }
 
+        final CountDownLatch latch = new CountDownLatch(oldMainBrownoutsMap.keySet().size());
 
-                    lastStatus = currentStatus;
-                }
-
-            }
-            //循环结束落盘,并清空
-            if (oldMainBrownoutsMap.containsKey(wpId)) {
-                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
-                mainBrownouts = oldMainBrownoutsMap.get(wpId);
-
-                if (mainBrownouts != null) {
-                    ProEconMainBrownouts finalItem = mainBrownouts;
-                    QueryWrapper<ProEconMainBrownouts> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
-                    List<ProEconMainBrownouts> ls = proEconMainBrownoutsService.list(queryWrapper5);
-//                            .stream()
-//                            .filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
-//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0)
-                    //.collect(Collectors.toList());
+        //遍历PG数据库中存在的记录,恢复时间为空的集合
+        for (String wpId : oldMainBrownoutsMap.keySet()) {
 //
-                    if (ls.isEmpty()) {
-                        proEconMainBrownoutsService.save(finalItem);
-                        oldMainBrownoutsMap.put(wpId, null);
-
-                        if (newMainBrownoutsMap.containsKey(wpId)) {
-                            Map<String, ProEconMainBrownouts> mbmap = newMainBrownoutsMap.get(wpId);
-                            mbmap.put(String.valueOf(mainBrownouts.getStopTime().getTime()), mainBrownouts);
-                        } else {
-                            Map<String, ProEconMainBrownouts> mbmap = new HashMap<>();
-                            mbmap.put(String.valueOf(mainBrownouts.getStopTime().getTime()), mainBrownouts);
-                            newMainBrownoutsMap.put(wpId, mbmap);
-                        }
-                    }
-                }
-
-
-            }
-
-
-            if (oldMainBrownouts2Map.containsKey(wpId)) {
-                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
-                mainBrownouts2 = oldMainBrownouts2Map.get(wpId);
-                if (mainBrownouts2 != null) {
-                    ProEconMainBrownouts2 finalItem = mainBrownouts2;
-                    QueryWrapper<ProEconMainBrownouts2> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
-                    List<ProEconMainBrownouts2> ls = proEconMainBrownouts2Service.list(queryWrapper5);
-//                            .stream().filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
-//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0).collect(Collectors.toList());
-
-                    if (ls.isEmpty()) {
-                        proEconMainBrownouts2Service.save(finalItem);
-                        oldMainBrownouts2Map.put(wpId, null);
-
-                        if (newMainBrownouts2Map.containsKey(wpId)) {
-                            Map<String, ProEconMainBrownouts2> mbmap = newMainBrownouts2Map.get(wpId);
-                            mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-                        } else {
-                            Map<String, ProEconMainBrownouts2> mbmap = new HashMap<>();
-                            mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-                            newMainBrownouts2Map.put(wpId, mbmap);
-                        }
-                    }
-
-                }
-
-            }
+//            new Thread(new MainBrownoutsThread(mainexecutor
+//                    ,  wpstatusMap,  wpId, oldMainBrownoutsMap, oldMainBrownouts2Map,  proEconMainBrownoutsService,  newMainBrownoutsMap,  newMainBrownouts2Map,  proEconMainBrownouts2Service,  edosUtil,  begin,  end)).start();
+//
+          new Thread(new MainBrownoutsThread(mainexecutor
+                    ,  wpstatusMap,  wpId, oldMainBrownoutsMap, oldMainBrownouts2Map,  proEconMainBrownoutsService,  newMainBrownoutsMap,  newMainBrownouts2Map,  proEconMainBrownouts2Service,  edosUtil,  begin,  end,latch)).start();
 
         }
+        latch.await();
 //*************************主表数据计算*****************************************************************************/
 
 //*************************子表数据计算*****************************************************************************/
         //遍历PG数据库中存在的记录,恢复时间为空的集合
         for (String wtId : oldBrownoutsStatusMap.keySet()) {
-            ProEconBrownoutsEvent brownoutsEvent = null;
-            ProEconBrownoutsEvent2 brownoutsEvent2;
-            //获取5分钟的状态值
-            List<PointData> statusls = statusMap.get(wtId);
-
-            Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
-            //记录上次判定的状态值
-            int lastStatus = (int) statusls.get(0).getPointValueInDouble();
-            for (PointData stpo : statusls) {
-                //获取当前状态
-                int currentStatus = (int) stpo.getPointValueInDouble();
-                //获取当前时间
-                Date currentTime = new Date(stpo.getPointTime());
-                //如果数据库中不存在该风机未完成的故障记录,进入
-                if (brownoutsEvent == null) {
-                    if (currentStatus == 8 || currentStatus == 9) {
-                        brownoutsEvent = new ProEconBrownoutsEvent();
-                        initialBrownoutsEvent(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent);
-                        oldBrownoutsStatusMap.put(wtId, brownoutsEvent);
-
-                        brownoutsEvent2 = new ProEconBrownoutsEvent2();
-                        initialBrownoutsEvent2(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent2);
-                        oldBrownoutsStatus2Map.put(wtId, brownoutsEvent2);
-                    }
-
-
-                    //将当前状态赋值给过去状态
-                    lastStatus = currentStatus;
-                } else if (lastStatus != currentStatus) {
-
-                    //如果添加了状态值,状态值变化存储,并清空
-                    if (oldBrownoutsStatusMap.containsKey(wtId)) {
-
-                        //获取数据库中的状态值,状态值变化存储,并清空
-                        brownoutsEvent = oldBrownoutsStatusMap.get(wtId);
-                        if (brownoutsEvent == null) {
-                            brownoutsEvent = new ProEconBrownoutsEvent();
-                            initialBrownoutsEvent(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent);
-                            oldBrownoutsStatusMap.put(wtId, brownoutsEvent);
-                        } else {
-                            finishBrownoutsEvent(wtId, brownoutsEvent, currentTime);
-                            oldBrownoutsStatusMap.put(wtId, null);
-                            brownoutsEvent = null;
-                        }
-
-
-                    }
-
-                    if (oldBrownoutsStatus2Map.containsKey(wtId)) {
-
-                        //获取数据库中的状态值,状态值变化存储,并清空
-                        brownoutsEvent2 = oldBrownoutsStatus2Map.get(wtId);
-                        if (brownoutsEvent2 == null) {
-                            brownoutsEvent2 = new ProEconBrownoutsEvent2();
-                            initialBrownoutsEvent2(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent2);
-                            oldBrownoutsStatus2Map.put(wtId, brownoutsEvent2);
-                        } else {
-                            finishBrownoutsEvent2(wtId, brownoutsEvent2, currentTime);
-                            oldBrownoutsStatus2Map.put(wtId, null);
-                        }
-
-
-                    }
-
-
-                    lastStatus = currentStatus;
-                }
-
-
-            }
-            //循环结束落盘,并清空
-            if (oldBrownoutsStatusMap.containsKey(wtId)) {
-                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
-                brownoutsEvent = oldBrownoutsStatusMap.get(wtId);
-                if (brownoutsEvent != null) {
-                    ProEconBrownoutsEvent finalItem = brownoutsEvent;
-                    QueryWrapper<ProEconBrownoutsEvent> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
-                    List<ProEconBrownoutsEvent> ls = proEconBrownoutsEventService.list(queryWrapper5);
-//                            .stream().filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
-//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0).collect(Collectors.toList());
-
-                    if (ls.isEmpty()) {
-                        proEconBrownoutsEventService.save(finalItem);
-                        oldBrownoutsStatusMap.put(wtId, null);
-
-                    }
-                }
-
-
-            }
-
-
-            if (oldBrownoutsStatus2Map.containsKey(wtId)) {
-                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
-                brownoutsEvent2 = oldBrownoutsStatus2Map.get(wtId);
-                if (brownoutsEvent2 != null) {
-                    ProEconBrownoutsEvent2 finalItem = brownoutsEvent2;
-                    QueryWrapper<ProEconBrownoutsEvent2> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
-                    List<ProEconBrownoutsEvent2> ls = proEconBrownoutsEvent2Service.list(queryWrapper5);
-//                            .stream().filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
-//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0).collect(Collectors.toList());
-
-                    if (ls.isEmpty()) {
-                        proEconBrownoutsEvent2Service.save(finalItem);
-                        oldBrownoutsStatus2Map.put(wtId, null);
 
-                    }
-                }
-
-            }
+            new Thread(new BrownoutsThread(executor,
+                    statusMap,  wtId, oldBrownoutsStatusMap,oldBrownoutsStatus2Map,
+                    proEconBrownoutsEventService,
+                    proEconBrownoutsEvent2Service,
+                    statusDescriptionMap,
+                    newMainBrownouts2Map,
+                    newMainBrownoutsMap,
+                    edosUtil,  begin,  end)).start();
 
         }
 //*************************子表数据计算*****************************************************************************/
@@ -435,603 +213,6 @@ public class LimitEventnewService {
 
     }
 
-    private void initialBrownoutsEvent(String wtId, Map<String, ProBasicEquipmentPoint> wtpointmap, Integer currentStatus, Date currentTime, ProEconBrownoutsEvent sub) throws Exception {
-        ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
-        Map<String, ProEconMainBrownouts> timemap = null;
-        if (newMainBrownoutsMap.containsKey(wt.getWindpowerstationId())) {
-            timemap = newMainBrownoutsMap.get(wt.getWindpowerstationId());
-        } else {
-            timemap = new HashMap<>();
-            newMainBrownoutsMap.put(wt.getWindpowerstationId(), timemap);
-        }
-        if (timemap.containsKey(String.valueOf(currentTime))) {
-            ProEconMainBrownouts mainObj = timemap.get(String.valueOf(currentTime));
-            sub.setMainId(mainObj.getId());
-        }
-
-
-        sub.setId(StringUtils.getUUID());
-        sub.setWindpowerstationId(wt.getWindpowerstationId());
-        sub.setWindturbineId(wt.getId());
-        sub.setProjectId(wt.getProjectId());
-        sub.setLineId(wt.getLineId());
-        sub.setStopTime(currentTime);
-        sub.setStartTime(null);
-        sub.setStopHours(0.0);
-        sub.setLossPower(0.0);
-
-        sub.setStopTypeId(statusDescriptionMap.get(currentStatus));
-
-
-        PointData data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSGL));
-        sub.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
-        data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSFS));
-        sub.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
-
-
-        long pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
-        List<PointData> hsls = edosUtil.getHistStat(wtpointmap.get(ContantXk.CJ_SSGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
-        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
-            sub.setThisLoad(hsls.get(0).getPointValueInDouble());
-
-
-            oldBrownoutsStatusMap.put(wtId, sub);
-        }
-
-    }
-
-    private void initialBrownoutsEvent2(String wtId, Map<String, ProBasicEquipmentPoint> wtpointmap, Integer currentStatus, Date currentTime, ProEconBrownoutsEvent2 sub) throws Exception {
-        ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
-        Map<String, ProEconMainBrownouts2> timemap = null;
-        if (newMainBrownouts2Map.containsKey(wt.getWindpowerstationId())) {
-            timemap = newMainBrownouts2Map.get(wt.getWindpowerstationId());
-
-        }else
-        {
-            timemap=new HashMap<>();
-            newMainBrownouts2Map.put(wt.getWindpowerstationId(),timemap);
-        }
-        if (timemap.containsKey(String.valueOf(currentTime))) {
-            ProEconMainBrownouts2 mainObj = timemap.get(String.valueOf(currentTime));
-            sub.setMainId(mainObj.getId());
-        }
-
-        sub.setId(StringUtils.getUUID());
-        sub.setWindpowerstationId(wt.getWindpowerstationId());
-        sub.setWindturbineId(wt.getId());
-        sub.setProjectId(wt.getProjectId());
-        sub.setLineId(wt.getLineId());
-        sub.setStopTime(currentTime);
-        sub.setStartTime(null);
-        sub.setStopHours(0.0);
-        sub.setLossPower(0.0);
-        sub.setStopTypeId(statusDescriptionMap.get(currentStatus));
-
-
-        PointData data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSGL));
-        sub.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
-        data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSFS));
-        sub.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
-
-
-        long pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
-        List<PointData> hsls = edosUtil.getHistStat(wtpointmap.get(ContantXk.CJ_SSGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
-        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
-            sub.setThisLoad(hsls.get(0).getPointValueInDouble());
-
-        }
-
-        oldBrownoutsStatus2Map.put(wtId, sub);
-
-
-    }
-
-    private void intialainBrownouts2(String wpId, Map<String, ProBasicPowerstationPoint> wppointmap, Date currentTime, ProEconMainBrownouts2 mainBrownouts2) throws Exception {
-        PointData data;
-        long pried;
-        List<PointData> hsls;
-        mainBrownouts2.setId(StringUtils.getUUID());
-        mainBrownouts2.setStopTime(currentTime);
-        mainBrownouts2.setStartTime(null);
-        mainBrownouts2.setStopTypeId("限电");
-        data = edosUtil.getRealData(wppointmap.get(ContantXk.SSZGL));
-        mainBrownouts2.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
-        data = edosUtil.getRealData(wppointmap.get(ContantXk.SSPJFS));
-        mainBrownouts2.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
-
-
-        pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
-        hsls = edosUtil.getHistStat(wppointmap.get(ContantXk.SSZGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
-        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
-            mainBrownouts2.setThisLoad(hsls.get(0).getPointValueInDouble());
-
-        }
-
-        mainBrownouts2.setWindpowerstationId(wpId);
-        mainBrownouts2.setLossPower(0.0);
-    }
-
-    private void intialainBrownouts(String wpId, Map<String, ProBasicPowerstationPoint> wppointmap, Date currentTime, ProEconMainBrownouts mainBrownouts) throws Exception {
-
-
-        mainBrownouts.setId(StringUtils.getUUID());
-        mainBrownouts.setStopTime(currentTime);
-        mainBrownouts.setStartTime(null);
-        mainBrownouts.setStopTypeId("限电");
-        PointData data = edosUtil.getRealData(wppointmap.get(ContantXk.SSZGL));
-        mainBrownouts.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
-        data = edosUtil.getRealData(wppointmap.get(ContantXk.SSPJFS));
-        mainBrownouts.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
-
-
-        long pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
-        List<PointData> hsls = edosUtil.getHistStat(wppointmap.get(ContantXk.SSZGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
-        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
-            mainBrownouts.setThisLoad(hsls.get(0).getPointValueInDouble());
-
-        }
-        mainBrownouts.setWindpowerstationId(wpId);
-        mainBrownouts.setLossPower(0.0);
-    }
-
-
-    private void finishMainBrownouts2(String wpId, ProEconMainBrownouts2 mainBrownouts2, Date currentTime) throws Exception {
-//        if(currentStatus != 4 )
-//        {
-        mainBrownouts2.setStartTime(currentTime);
-
-        double timehour = DateUtils.hoursDiff2(mainBrownouts2.getStartTime(), mainBrownouts2.getStopTime());
-        mainBrownouts2.setStopHours(timehour);
-        double losspower = calWpLossPower(wpId, mainBrownouts2.getStartTime(), mainBrownouts2.getStopTime());
-        mainBrownouts2.setLossPower(losspower);
-
-        if (timehour <= 24) {
-            proEconMainBrownouts2Service.saveOrUpdate(mainBrownouts2);
-
-            if (newMainBrownouts2Map.containsKey(wpId)) {
-                Map<String, ProEconMainBrownouts2> mbmap = newMainBrownouts2Map.get(wpId);
-                mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-            } else {
-                Map<String, ProEconMainBrownouts2> mbmap = new HashMap<>();
-                mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-                newMainBrownouts2Map.put(wpId, mbmap);
-            }
-        } else {
-            int days = DateUtils.daysDiff1(mainBrownouts2.getStartTime(), mainBrownouts2.getStopTime());
-            Calendar c = Calendar.getInstance();
-            Date startTime = mainBrownouts2.getStartTime();
-            c.setTime(mainBrownouts2.getStopTime());
-            c.set(Calendar.HOUR_OF_DAY, 23);
-            c.set(Calendar.MINUTE, 59);
-            c.set(Calendar.SECOND, 59);
-            for (int i = 0; i < days; i++) {
-                if (i == 0) {
-                    mainBrownouts2.setStartTime(c.getTime());
-                    losspower = calWpLossPower(wpId, mainBrownouts2.getStartTime(), mainBrownouts2.getStopTime());
-
-                } else {
-                    mainBrownouts2.setStopTime(DateUtils.truncate(c.getTime()));
-                    if (i == days - 1) {
-                        mainBrownouts2.setStartTime(startTime);
-
-                    } else {
-                        mainBrownouts2.setStartTime(c.getTime());
-
-                    }
-                    losspower = calWpLossPower(wpId, mainBrownouts2.getStartTime(), mainBrownouts2.getStopTime());
-                }
-                mainBrownouts2.setLossPower(losspower);
-                proEconMainBrownouts2Service.saveOrUpdate(mainBrownouts2);
-
-                if (newMainBrownouts2Map.containsKey(wpId)) {
-                    Map<String, ProEconMainBrownouts2> mbmap = newMainBrownouts2Map.get(wpId);
-                    mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-                } else {
-                    Map<String, ProEconMainBrownouts2> mbmap = new HashMap<>();
-                    mbmap.put(String.valueOf(mainBrownouts2.getStopTime().getTime()), mainBrownouts2);
-                    newMainBrownouts2Map.put(wpId, mbmap);
-                }
-
-                c.add(Calendar.DAY_OF_MONTH, 1);
-            }
-        }
-
-
-//        }
-
-    }
-
-    private void finishMainBrownouts(String wpId, ProEconMainBrownouts item, Date currentTime) throws Exception {
-//        if(currentStatus != 4 )
-//        {
-        item.setStartTime(currentTime);
-        double timehour = DateUtils.hoursDiff2(item.getStartTime(), item.getStopTime());
-        item.setStopHours(timehour);
-        double losspower = calWpLossPower(wpId, item.getStartTime(), item.getStopTime());
-        item.setLossPower(losspower);
-        proEconMainBrownoutsService.saveOrUpdate(item);
-
-        if (newMainBrownoutsMap.containsKey(wpId)) {
-            Map<String, ProEconMainBrownouts> mbmap = newMainBrownoutsMap.get(wpId);
-            mbmap.put(String.valueOf(item.getStopTime().getTime()), item);
-        } else {
-            Map<String, ProEconMainBrownouts> mbmap = new HashMap<>();
-            mbmap.put(String.valueOf(item.getStopTime().getTime()), item);
-            newMainBrownoutsMap.put(wpId, mbmap);
-        }
-//        }
-    }
-
-
-    private void finishBrownoutsEvent(String wpId, ProEconBrownoutsEvent item, Date currentTime) throws Exception {
-//        if (currentStatus != 8 && currentStatus != 9)
-//        {
-        item.setStartTime(currentTime);
-        double timehour = DateUtils.hoursDiff2(item.getStartTime(), item.getStopTime());
-        item.setStopHours(timehour);
-        double losspower = calLossPower(wpId, item.getStartTime(), item.getStopTime());
-        item.setLossPower(losspower);
-        proEconBrownoutsEventService.saveOrUpdate(item);
-
-
-        //       }
-    }
-
-    private void finishBrownoutsEvent2(String wpId, ProEconBrownoutsEvent2 brownoutsEvent2, Date currentTime) throws Exception {
-//        if (currentStatus != 8 && currentStatus != 9)
-//        {
-        brownoutsEvent2.setStartTime(currentTime);
-
-        double timehour = DateUtils.hoursDiff2(brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
-        brownoutsEvent2.setStopHours(timehour);
-        double losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
-        brownoutsEvent2.setLossPower(losspower);
-
-        if (timehour <= 24) {
-            proEconBrownoutsEvent2Service.saveOrUpdate(brownoutsEvent2);
-        } else {
-            int days = DateUtils.daysDiff1(brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
-            Calendar c = Calendar.getInstance();
-            Date startTime = brownoutsEvent2.getStartTime();
-            c.setTime(brownoutsEvent2.getStopTime());
-            c.set(Calendar.HOUR_OF_DAY, 23);
-            c.set(Calendar.MINUTE, 59);
-            c.set(Calendar.SECOND, 59);
-            for (int i = 0; i < days; i++) {
-                if (i == 0) {
-                    brownoutsEvent2.setStartTime(c.getTime());
-                    losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
-
-                } else {
-                    brownoutsEvent2.setStopTime(DateUtils.truncate(c.getTime()));
-                    if (i == days - 1) {
-                        brownoutsEvent2.setStartTime(startTime);
-
-                    } else {
-                        brownoutsEvent2.setStartTime(c.getTime());
-
-                    }
-                    losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
-                }
-                brownoutsEvent2.setLossPower(losspower);
-                proEconBrownoutsEvent2Service.saveOrUpdate(brownoutsEvent2);
-
-
-                c.add(Calendar.DAY_OF_MONTH, 1);
-            }
-        }
-
-
-//        }
-
-    }
-
-    //修改后的限电损失统计,通过时序数据库历史切面计算
-    private Double calWpLossPower(String wpId, Date startDate, Date endDate) throws Exception {
-        double result = 0.0;
-
-        Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = CacheContext.wppointmap;
-        Map<String, ProBasicPowerstationPoint> wtpointmap = wppointmap.get(wpId);
-
-        Calendar c1 = Calendar.getInstance();
-        c1.setTime(startDate);
-        Calendar c2 = Calendar.getInstance();
-        c2.setTime(endDate);
-        //判定限电是否跨年
-        if (endDate.after(startDate) && c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
-            //年限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-            //年限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-        } else {
-            Calendar c = Calendar.getInstance();
-            c.setTime(DateUtils.truncate(startDate));
-            c.add(Calendar.DAY_OF_MONTH, 1);
-            //获得1月1日零点值
-            Date endtime = c.getTime();
-            //年限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-            //年限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-
-            //日限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdend.size() == 1) {
-
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > 0) {
-                        result = result + endvalue;
-                    }
-                }
-            }
-
-            //日限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdend.size() == 1) {
-
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > 0) {
-                        result = result + endvalue;
-                    }
-                }
-            }
-        }
-
-
-        return result;
-
-    }
-
-    //修改后的限电损失统计,通过时序数据库历史切面计算
-    private Double calLossPower(String windturbineId, Date startDate, Date endDate) throws Exception {
-        double result = 0.0;
-
-        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
-        Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
-
-        Calendar c1 = Calendar.getInstance();
-        c1.setTime(startDate);
-        Calendar c2 = Calendar.getInstance();
-        c2.setTime(endDate);
-        //判定限电是否跨年
-        if (endDate.after(startDate) && c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
-            //年限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-            //年限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-        } else {
-            Calendar c = Calendar.getInstance();
-            c.setTime(DateUtils.truncate(startDate));
-            c.add(Calendar.DAY_OF_MONTH, 1);
-            //获得1月1日零点值
-            Date endtime = c.getTime();
-            //年限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
 
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-            //年限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-                double beginvalue;
-                double endvalue;
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
-
-
-                if (xdbegin.size() == 1 && xdend.size() == 1) {
-                    beginvalue = xdbegin.get(0).getPointValueInDouble();
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > beginvalue) {
-                        result = result + (endvalue - beginvalue);
-                    }
-                }
-            }
-
-
-            //日限电欠发损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
-
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
-
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdend.size() == 1) {
-
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > 0) {
-                        result = result + endvalue;
-                    }
-                }
-            }
-
-            //日限电损失电量
-            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
-
-                double endvalue;
-
-
-                List<String> pointid = new ArrayList<>();
-                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
-
-                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
-
-
-                if (xdend.size() == 1) {
-
-                    endvalue = xdend.get(0).getPointValueInDouble();
-
-                    if (endvalue > 0) {
-                        result = result + endvalue;
-                    }
-                }
-            }
-        }
-
-
-        return result;
-
-    }
 
 }

+ 157 - 107
realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeGfService.java

@@ -25,14 +25,14 @@ import java.util.stream.Collectors;
 @Service
 public class PowerCurveFittingByTimeGfService {
 
-    private static final Logger logger = LoggerFactory.getLogger(PowerCurveFittingByTimeGfService.class);
+    private static final Logger logger = LoggerFactory.getLogger(PowerCurveFittingByTimeService.class);
     @Resource
     private IEdosUtil edosUtil;
 
     @Value("${curvefitting.dimension}")
     private Integer dimension;
-
-    private Double scale=1.0;
+    @Value("${curvefitting.scale}")
+    private Double scale;
     @Value("${initialcode}")
     private String initialcode;
     public Map<String, Double> windturbineCapacity;
@@ -74,9 +74,9 @@ public class PowerCurveFittingByTimeGfService {
 
         Date begin = DateUtils.addDays(end, -6);
 
-        proEconWtCurveFittingService.deleteProEconWtCurveFittingGByDay(DateUtils.truncate(recordDate));
-        proEconCurveFittingMainService.deleteProEconCurveFittingMainGByDay(DateUtils.truncate(recordDate));
-        proEconCurveFittingSubService.deleteProEconCurveFittingSubGByDay(DateUtils.truncate(recordDate));
+        proEconWtCurveFittingService.deleteProEconWtCurveFittingFByDay(DateUtils.truncate(recordDate));
+        proEconCurveFittingMainService.deleteProEconCurveFittingMainFByDay(DateUtils.truncate(recordDate));
+        proEconCurveFittingSubService.deleteProEconCurveFittingSubFByDay(DateUtils.truncate(recordDate));
         Map<String, CureFittingVo> windMap = new HashMap<>();
 
         //初始化风机装机容量
@@ -94,10 +94,12 @@ public class PowerCurveFittingByTimeGfService {
         for (ProBasicEquipment wt : CacheContext.wtls) {
             String windturbineId = wt.getId();
 
-            if(wt.getWindpowerstationId().contains(WpType.FDC.id))
+            if(wt.getWindpowerstationId().contains(WpType.GDC.id))
             {
                 continue;
             }
+
+
             Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
             //设备有功功率
             String pointIdGL = null;
@@ -153,9 +155,9 @@ public class PowerCurveFittingByTimeGfService {
 
             //拟合日功率曲线
             curveFittingBuilder(begin, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getRsjglPoints(), windMap.get(key).getRzyglPoints(), key);
-            List<PointVo> vos = windMap.get(key).getRsjglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 1200).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
+            List<PointVo> vos = windMap.get(key).getRsjglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
             windMap.get(key).setRsjglPoints(vos);
-            vos = windMap.get(key).getRzyglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 1200).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
+            vos = windMap.get(key).getRzyglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
             windMap.get(key).setRzyglPoints(vos);
 
         }
@@ -164,7 +166,7 @@ public class PowerCurveFittingByTimeGfService {
         List<ProEconCurveFittingMain> mainls=new ArrayList<>();
         for (String key : windMap.keySet()) {
 
-            Double modelpower = 500.0;
+            Double modelpower = 1500.0;
             if (windturbineCapacity.containsKey(key)) {
                 modelpower = windturbineCapacity.get(key);
             }
@@ -306,9 +308,9 @@ public class PowerCurveFittingByTimeGfService {
         int day_month = c.get(Calendar.MONTH) + 1;
 
 
-        proEconWtCurveFittingMonthService.deleteProEconWtCurveFittingGByMonth(String.valueOf(day_year),String.valueOf(day_month));
-        proEconCurveFittMonthMainService.deleteProEconCurveFittMonthMainGByMonth(String.valueOf(day_year),String.valueOf(day_month));
-        proEconCurveFittMonthSubService.deleteProEconCurveFittMonthSubGByMonth(String.valueOf(day_year),String.valueOf(day_month));
+        proEconWtCurveFittingMonthService.deleteProEconWtCurveFittingFByMonth(String.valueOf(day_year),String.valueOf(day_month));
+        proEconCurveFittMonthMainService.deleteProEconCurveFittMonthMainFByMonth(String.valueOf(day_year),String.valueOf(day_month));
+        proEconCurveFittMonthSubService.deleteProEconCurveFittMonthSubFByMonth(String.valueOf(day_year),String.valueOf(day_month));
         c.set(Calendar.DAY_OF_MONTH, 1);
         Date begin = c.getTime();
 
@@ -337,26 +339,37 @@ public class PowerCurveFittingByTimeGfService {
         for (ProBasicEquipment wt : CacheContext.wtls) {
             String windturbineId = wt.getId();
 
-            if(wt.getWindpowerstationId().contains(WpType.FDC.id))
+            if(wt.getWindpowerstationId().contains(WpType.GDC.id))
             {
                 continue;
             }
             Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
             //设备有功功率
-            String pointIdGL = null;
+            String pointIdGL = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL).getNemCode();
             //设备明细状态
-            String pointIdZT = null;
+            String pointIdZT = windturbinetestingpointnewMap.get(ContantXk.MXZT).getNemCode();
 
-            String pointIdFS = null;
-            if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSFS)) {
+            String pointIdFS;
+            if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {   //测风塔70米风速
+
+                if (windturbinetestingpointnewMap.containsKey(ContantXk.FCCFTFS70)) {
+                    ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70);
+
+                    if (StringUtils.notEmp(point.getNemCode()) && !point.getNemCode().equals(initialcode)) {
+                        pointIdFS = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70).getNemCode();
+                    } else {
+                        pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
+                    }
+                } else {
+                    pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
+                }
+
+
+            } else {   //设备风速
                 pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
             }
-            if (windturbinetestingpointnewMap.containsKey(ContantXk.MXZT)) {
-                pointIdZT = windturbinetestingpointnewMap.get(ContantXk.MXZT).getNemCode();
-            }
-            if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSGL)) {
-                pointIdGL = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL).getNemCode();
-            }
+
+
             CureFittingVo item = new CureFittingVo();
 
             item.setPointIdFS(pointIdFS);
@@ -390,16 +403,18 @@ public class PowerCurveFittingByTimeGfService {
             //拟合月功率曲线
             curveFittingBuilder(begin, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), key);
 
-            List<PointVo> vos = windMap.get(key).getYsjglPoints().stream().filter(it -> it.getX() >= 0 ).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
+            List<PointVo> vos = windMap.get(key).getYsjglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
             windMap.get(key).setYsjglPoints(vos);
-            vos = windMap.get(key).getYzyglPoints().stream().filter(it -> it.getX() >= 0 ).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
+            vos = windMap.get(key).getYzyglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
             windMap.get(key).setYzyglPoints(vos);
 
+            logger.info(key+"曲线拟合完成!");
         }
+        logger.info("曲线拟合完成!");
         List<ProEconCurveFittMonthMain> mainls=new ArrayList<>();
         for (String key : windMap.keySet()) {
 
-            Double modelpower = 500.0;
+            Double modelpower = 1500.0;
             if (windturbineCapacity.containsKey(key)) {
                 modelpower = windturbineCapacity.get(key);
             }
@@ -471,6 +486,7 @@ public class PowerCurveFittingByTimeGfService {
                     }
                 }
             }
+
 //*********************************************年曲线偏差记录**********************************************************/
 
 
@@ -534,14 +550,14 @@ public class PowerCurveFittingByTimeGfService {
                 insertPoints2( windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), key);
             }
 
-
-            logger.info(key);
-//
+            logger.info(key+"月曲线偏差率完成!");
 //            logger.info(String.format("{1}:更新sqlserver数据库记录数:{0}", z, new Date()));
 
 
         }
         proEconCurveFittMonthMainService.saveBatch(mainls);
+
+        logger.info("曲线保存完成!");
     }
 
 
@@ -555,9 +571,9 @@ public class PowerCurveFittingByTimeGfService {
         int day_year = c.get(Calendar.YEAR);
 
 
-        proEconWtCurveFittingYearService.deleteProEconWtCurveFittingGByYear(String.valueOf(day_year));
-        proEconCurveFittYearMainService.deleteProEconCurveFittYearMainGByYear(String.valueOf(day_year));
-        proEconCurveFittYearSubService.deleteProEconCurveFittYearSubGByYear(String.valueOf(day_year));
+        proEconWtCurveFittingYearService.deleteProEconWtCurveFittingFByYear(String.valueOf(day_year));
+        proEconCurveFittYearMainService.deleteProEconCurveFittYearMainFByYear(String.valueOf(day_year));
+        proEconCurveFittYearSubService.deleteProEconCurveFittYearSubFByYear(String.valueOf(day_year));
         c.set(Calendar.DAY_OF_MONTH, 1);
         c.set(Calendar.MONTH, 0);
         Date begin = c.getTime();
@@ -583,7 +599,7 @@ public class PowerCurveFittingByTimeGfService {
         for (ProBasicEquipment wt : CacheContext.wtls) {
             String windturbineId = wt.getId();
 
-            if(wt.getWindpowerstationId().contains(WpType.FDC.id))
+            if(wt.getWindpowerstationId().contains(WpType.GDC.id))
             {
                 continue;
             }
@@ -685,7 +701,7 @@ public class PowerCurveFittingByTimeGfService {
         List<ProEconCurveFittYearMain> mainls=new ArrayList<>();
         for (String key : windMap.keySet()) {
 
-            Double modelpower = 500.0;
+            Double modelpower = 1500.0;
             if (windturbineCapacity.containsKey(key)) {
                 modelpower = windturbineCapacity.get(key);
             }
@@ -824,7 +840,7 @@ public class PowerCurveFittingByTimeGfService {
                                            List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
     ) {
 
-        //  String speedStr = String.valueOf(speed);
+//        String speedStr = String.valueOf(speed);
 
 //*********************************************当日曲线偏差子表记录**********************************************************/
         QueryWrapper<ProEconCurveFittingSub> queryWrapper2 = new QueryWrapper<>();
@@ -871,7 +887,7 @@ public class PowerCurveFittingByTimeGfService {
     public ProEconCurveFittMonthSub pLCBuild(String key, String stringyear, String stringmonth, Map<String, CureFittingVo> windMap, Double modelpower, double speed,
                                              List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
     ) {
-        //   String speedStr = String.valueOf(speed);
+//        String speedStr = String.valueOf(speed);
 
         //*********************************************当月曲线偏差子表记录**********************************************************/
         QueryWrapper<ProEconCurveFittMonthSub> queryWrapper2 = new QueryWrapper<>();
@@ -921,7 +937,7 @@ public class PowerCurveFittingByTimeGfService {
     public ProEconCurveFittYearSub pLCBuild(String key, String stringyear, Map<String, CureFittingVo> windMap, Double modelpower, double speed,
                                             List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
     ) {
-        //
+//        String speedStr = String.valueOf(speed);
 
         //*********************************************当年曲线偏差子表记录**********************************************************/
         QueryWrapper<ProEconCurveFittYearSub> queryWrapper = new QueryWrapper<>();
@@ -1387,64 +1403,54 @@ public class PowerCurveFittingByTimeGfService {
     }
 
     //todo-sl 添加数据筛选
-    private boolean filterData(PointData gl, PointData fs, PointData zt, double maxPower,double maxSpeed, String windturbineId) throws Exception {
+    private boolean filterData(PointData gl, PointData fs, List<PointData> ztls,List<PointData> qfztls,int i, double maxPower,double maxSpeed, String windturbineId) throws Exception {
         if (StringUtils.notEmp(gl)) {
             //判定功率是否超过最大值
-            if (gl.getPointValueInDouble() > maxPower) {
+            if (gl.getPointValueInDouble() > maxPower || gl.getPointValueInDouble()<0) {
                 return false;
             }
         }
 
         if (StringUtils.notEmp(fs)) {
             //判定功率是否超过最大值
-            if (fs.getPointValueInDouble() > maxSpeed) {
+            if (fs.getPointValueInDouble() > maxSpeed || fs.getPointValueInDouble()<0) {
                 return false;
             }
         }
 
-//        //判定状态不为运行的进行过滤
-//        if (zt.getPointValueInDouble() != 2) {
-//            return false;
-//        }
-//
+        //判定状态不为运行的进行过滤
+        if (ztls.get(i).getPointValueInDouble() != 2) {
+            return false;
+        }
+
+
+        if(i<10)
+        {
+            return false;
+        }else {
+
+            for(int j=i-10;j<i;j++)
+            {
+                //设置时间为10分钟前,10钟前有停机事件数据进行过滤
+                if (ztls.get(j).getPointValueInDouble() == 4) {
+
+                    return false;
+                }
+                //设置时间为10分钟后,运行后10分钟数据进行过滤
+                if (ztls.get(j).getPointValueInDouble() != 2) {
+
+                    return false;
+                }
+            }
+        }
+
+
+
+
+
+
+
 
-//        //设置时间为10分钟前,10钟前有停机事件数据进行过滤
-//        Calendar c = Calendar.getInstance();
-//        c.setTimeInMillis(zt.getPointTime());
-//        Date end = c.getTime();
-//        c.add(Calendar.MINUTE, -10);
-//        Date bedin = c.getTime();
-//        List<PointData> points = edosUtil.getHistoryDatasSnap(zt.getEdnaId(), bedin.getTime() / 1000, end.getTime() / 1000);
-//        if (!points.isEmpty()) {
-//            for (PointData p : points) {
-//                if (p.getPointValueInDouble() == 4) {
-//
-//                    return false;
-//                }
-//
-//            }
-//
-//        }
-//
-//        //设置时间为10分钟后,运行后10分钟数据进行过滤
-//
-//        points = edosUtil.getHistoryDatasSnap(zt.getEdnaId(), bedin.getTime() / 1000, end.getTime() / 1000);
-//        if (!points.isEmpty()) {
-//            for (PointData p : points) {
-//                if (p.getPointValueInDouble() != 2) {
-//                    return false;
-//
-//                }
-//
-//            }
-//
-//        }
-//
-//
-//        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
-//        Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
-//
-//
 //        List<PointVo> bzPointls=new ArrayList<>();
 //        List<PointVo> sjPointls=new ArrayList<>();
 //
@@ -1460,6 +1466,7 @@ public class PowerCurveFittingByTimeGfService {
 //                    double speed=StringUtils.round(fs.getPointValueInDouble(),2);
 //                    point.setX(speed);
 //                    point.setY(theoreticalMap.get(speed).getEnsurePower());
+//
 //                    modelpower=point.getY();
 //                    bzPointls.add(point);
 //                }
@@ -1472,38 +1479,81 @@ public class PowerCurveFittingByTimeGfService {
 //        point.setX(speed);
 //        point.setY(power);
 //        sjPointls.add(point);
-//
-//        //与保证功率进行对比,偏差大于25%的进行过滤
+
+        //与保证功率进行对比,偏差大于25%的进行过滤
 //        double value= pcl2( sjPointls, bzPointls, modelpower, speed);
 //
-//        if (value > Math.abs(0.25)) {
+//        if (0.25 > Math.abs(value)) {
 //            return false;
 //        }
-//
+
+        double modelpower=0.0;
+        if (CacheContext.wtmap.containsKey(windturbineId)) {
+            String modelid = CacheContext.wtmap.get(windturbineId).getModelId();
+            if (StringUtils.notEmp(modelid)) {
+                //获取保证功率曲线中的风速和功率
+                if (CacheContext.theoreticalPowerMap.containsKey(modelid)) {
+                    Map<Double,ProBasicModelPowerRd> theoreticalMap= CacheContext.theoreticalPowerMap.get(modelid);
+
+
+                    double speed=StringUtils.round(fs.getPointValueInDouble(),2);
+
+                    if(theoreticalMap.containsKey(speed))
+                    {
+                        modelpower=theoreticalMap.get(speed).getEnsurePower();
+                    }else
+                    {
+                        modelpower=0;
+                    }
+
+
+
+                }
+            }
+        }
+        if(gl.getPointValueInDouble()>(modelpower*1.25) || gl.getPointValueInDouble()<(modelpower*0.75))
+        {
+            return false;
+        }
+
+//        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+//        Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
 //        List<String> pointid = new ArrayList<>();
 //        //欠发状态大于2过滤掉
 //        pointid.add(wtpointmap.get(ContantXk.LSQFZT).getNemCode());
 //        List<PointData> values = edosUtil.getHistMatrix(pointid, gl.getPointTime() / 1000);
 //        if (null != values && values.size() > 0) {
-//            double qfzt = values.get(0).getPointValueInDouble();
+//            double qfzt = qfztls.get(i).getPointValueInDouble();
 //
 //            return !(qfzt > 2);
 //        }
+
+
+        //欠发状态大于2过滤掉
+        if (qfztls.get(i).getPointValueInDouble() > 2) {
+
+            return false;
+        }
         return true;
     }
 
     //功率曲线拟合
     private void curveFittingBuilder(Date begin, Date end, int dimension, double scale, String pointIdGL, String pointIdFS, String pointIdZT, List<PointVo> sjglPoints, List<PointVo> zyglPoints, String windturbineId) throws Exception {
         double maxPower = windturbineCapacity.get(windturbineId) * 1.3;
-        double maxSpeed = 1200;
+        double maxSpeed = 25;
         List<PointfVo> sjglnhpoints = new ArrayList<>();
         Map<Double, PointfVo> zyglnhpoints = new HashMap<>();
 
+        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+        Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
+        String qfzt= wtpointmap.get(ContantXk.LSQFZT).getNemCode();
+
         if (end.after(begin)) {
             if (StringUtils.notEmp(pointIdGL) && StringUtils.notEmp(pointIdFS)) {
                 List<PointData> glpointstemp = edosUtil.getHistoryDatasSnap(pointIdGL, begin.getTime() / 1000, end.getTime() / 1000);
                 List<PointData> fspointstemp = edosUtil.getHistoryDatasSnap(pointIdFS, begin.getTime() / 1000, end.getTime() / 1000);
                 List<PointData> ztpointstemp = edosUtil.getHistoryDatasSnap(pointIdZT, begin.getTime() / 1000, end.getTime() / 1000);
+                List<PointData> qfzttemp = edosUtil.getHistoryDatasSnap(qfzt, begin.getTime() / 1000, end.getTime() / 1000);
 
 
                 List<PointData> glpoints = new ArrayList<>();
@@ -1511,7 +1561,7 @@ public class PowerCurveFittingByTimeGfService {
                 List<PointData> ztpoints = new ArrayList<>();
                 if (!glpointstemp.isEmpty() && !fspointstemp.isEmpty() && !ztpointstemp.isEmpty() && glpointstemp.size() == fspointstemp.size() && fspointstemp.size() == ztpointstemp.size()) {
                     for (int i = 0; i < glpointstemp.size(); i++) {
-                        if (filterData(glpointstemp.get(i), fspointstemp.get(i), ztpointstemp.get(i), maxPower,maxSpeed, windturbineId)) {
+                        if (filterData(glpointstemp.get(i), fspointstemp.get(i), ztpointstemp,qfzttemp,i, maxPower,maxSpeed, windturbineId)) {
                             glpoints.add(glpointstemp.get(i));
                             fspoints.add(fspointstemp.get(i));
                             ztpoints.add(ztpointstemp.get(i));
@@ -1555,13 +1605,13 @@ public class PowerCurveFittingByTimeGfService {
                             } else {
                                 if (z == 2) {
 
-                                    b = (x >= 0 && x <= 1000 && y >= 0 && y <= maxPower);
+                                    b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
 
                                     if (b) {
-                                        if (x > 0 && y <= 0) {
+                                        if (x > 3 && y <= 0) {
                                             b = false;
                                         }
-                                        if (x <= 0 && y > 0) {
+                                        if (x <= 3 && y > 0) {
                                             b = false;
                                         }
                                     }
@@ -1611,13 +1661,13 @@ public class PowerCurveFittingByTimeGfService {
                             } else {
                                 if (z == 2) {
 
-                                    b = (x >= 0 && x <= 1000 && y >= 0 && y <= maxPower);
+                                    b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
 
                                     if (b) {
-                                        if (x > 0 && y <= 0) {
+                                        if (x > 3 && y <= 0) {
                                             b = false;
                                         }
-                                        if (x <= 0 && y > 0) {
+                                        if (x <= 3 && y > 0) {
                                             b = false;
                                         }
                                     }
@@ -1645,7 +1695,7 @@ public class PowerCurveFittingByTimeGfService {
                 }
                 sjglnhpoints.add(new PointfVo(0.0, 0.0));
 
-                sjglnhpoints = sjglnhpoints.stream().filter(it -> it.getX() >= 0).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
+                sjglnhpoints = sjglnhpoints.stream().filter(it -> it.getX() >= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
 //                if (sjglnhpoints.stream().min(Comparator.comparing(PointfVo::getX)).isPresent()) {
 //                    double  Xmax = sjglnhpoints.stream().max(Comparator.comparing(PointfVo::getX)).get().getX();
 //                    double  Ymax = sjglnhpoints.stream().max(Comparator.comparing(PointfVo::getX)).get().getY();
@@ -1663,7 +1713,7 @@ public class PowerCurveFittingByTimeGfService {
                 if (!zyglnhpoints.containsKey(0.0))
                     zyglnhpoints.put(0.0, new PointfVo(0.0, 0.0));
 
-                List<PointfVo> zygltemp = zyglnhpoints.values().stream().filter(it -> it.getX() >= 0).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
+                List<PointfVo> zygltemp = zyglnhpoints.values().stream().filter(it -> it.getX() >= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
                 if (zygltemp.size() != 0) {
                     temp = LineUtil.buildLine(zygltemp.stream().mapToDouble(PointfVo::getX).toArray(), zygltemp.stream().mapToDouble(PointfVo::getY).toArray(), zygltemp.size(), dimension, scale);
                 }
@@ -1678,15 +1728,15 @@ public class PowerCurveFittingByTimeGfService {
     private static void buildMyPoints(List<PointVo> sjglPoints, double scale) {
         int coefficient = 1;
         int dec = 0;
-        int smax = 1000;
-//        if (scale == 0.01) {
-//            coefficient = 100;
-//            dec = 2;
-//        }
-//        if (scale == 0.1) {
-//            coefficient = 10;
-//            dec = 1;
-//        }
+        int smax = 25;
+        if (scale == 0.01) {
+            coefficient = 100;
+            dec = 2;
+        }
+        if (scale == 0.1) {
+            coefficient = 10;
+            dec = 1;
+        }
 
         smax *= coefficient;
 

+ 9 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeService.java

@@ -1497,7 +1497,15 @@ public class PowerCurveFittingByTimeService {
 
 
                     double speed=StringUtils.round(fs.getPointValueInDouble(),2);
-                    modelpower=theoreticalMap.get(speed).getEnsurePower();
+
+                    if(theoreticalMap.containsKey(speed))
+                    {
+                        modelpower=theoreticalMap.get(speed).getEnsurePower();
+                    }else
+                    {
+                        modelpower=0;
+                    }
+
 
 
                 }

+ 28 - 248
realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java

@@ -9,6 +9,7 @@ import com.gyee.generation.service.auto.IProEconInterruptionService;
 import com.gyee.generation.service.auto.IProEconShutdownEvent2Service;
 import com.gyee.generation.service.auto.IProEconShutdownEventService;
 import com.gyee.generation.service.auto.IProEconWindturbineStatusService;
+import com.gyee.generation.task.ShutdownnewThread;
 import com.gyee.generation.util.DateUtils;
 import com.gyee.generation.util.StringUtils;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.Executor;
 import java.util.stream.Collectors;
 
 @Service
@@ -53,7 +55,8 @@ public class ShutdownnewService {
     Map<String, ProEconInterruption> oldInterrup = new HashMap<>();
     Map<String, ProEconShutdownEvent2> oldShutdownEvent2 = new HashMap<>();
 
-
+    @Resource
+    private Executor executor;
 
 
     public void execShutdown(Date recordDate) throws Exception {
@@ -84,19 +87,19 @@ public class ShutdownnewService {
 
         for (ProBasicEquipment wt : CacheContext.wtls)
         {
-            Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
-
-            //取实时状态数据 赋值给status
-
-            if(windturbinetestingpointnewMap.containsKey(ContantXk.MXZT))
-            {
-                ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
-                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
-                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
-
-                statusMap.put(wt.getId(), statusls);
-            }
-
+//            Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
+//
+//            //取实时状态数据 赋值给status
+//
+//            if(windturbinetestingpointnewMap.containsKey(ContantXk.MXZT))
+//            {
+//                ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
+//                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+//                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
+//
+//                statusMap.put(wt.getId(), statusls);
+//            }
+            statusMap.put(wt.getId(), null);
             //初始化将所有风机编号作为key,value全部赋值为null
             oldStatusMap.put(wt.getId(), null);
             oldShutdownEvent.put(wt.getId(), null);
@@ -164,244 +167,21 @@ public class ShutdownnewService {
         //遍历PG数据库中存在的记录,恢复时间为空的集合
         for (String windturbineId : oldStatusMap.keySet())
         {
-            ProEconWindturbineStatus item = oldStatusMap.get(windturbineId);
-            //获取5分钟的状态值
-            List<PointData> statusls=statusMap.get(windturbineId);
-
-            ProEconShutdownEvent shutdwonEvent=null;
-            ProEconInterruption interrup=null;
-            ProEconShutdownEvent2 shutdwonEvent2=null;
-            //记录上次判定的状态值
-            int lastStatus =(int)statusls.get(0).getPointValueInDouble();
-            for(PointData stpo:statusls)
-            {
-                //获取当前状态
-                Integer currentStatus = (int)stpo.getPointValueInDouble();
-                //获取当前时间
-                Date currentTime=new Date(stpo.getPointTime());
-                //如果数据库中不存在该风机未完成的故障记录,进入
-                if (item == null)
-                {
-
-                    item = new ProEconWindturbineStatus();
-
-                    initalWindturbineStatus(windturbineId, item, currentStatus, currentTime,stpo);
-
-                    if (currentStatus == 4 || currentStatus == 6)
-                    {
-                        shutdwonEvent=new ProEconShutdownEvent();
-                        initalShutdownEvent(windturbineId, item, currentStatus, currentTime, shutdwonEvent);
-
-
-                        shutdwonEvent2=new ProEconShutdownEvent2();
-                        initalShutdownEvent2(windturbineId, item, currentStatus, currentTime, shutdwonEvent2);
-
-
-                        item.setShutdownEventId(shutdwonEvent.getId());
-                    }
-                    if (currentStatus == 12)
-                    {
-                        interrup=new ProEconInterruption();
-                        initalInterruption(windturbineId, item, currentTime, interrup);
-                    }
-
-                    //将状态保存到MAP对象中
-                    oldStatusMap.put(item.getWindturbineId(),item);
-
-
-                    if (shutdwonEvent != null )
-                        {
-                            oldShutdownEvent.put(item.getWindturbineId(),shutdwonEvent);
-
-                        }
-                        if (interrup != null)
-                        {
-                            oldInterrup.put(item.getWindturbineId(),interrup);
-
-                        }
-                        if (shutdwonEvent2 != null)
-                        {
-                            oldShutdownEvent2.put(item.getWindturbineId(), shutdwonEvent2);
-                        }
-                    //将当前状态赋值给过去状态
-                    lastStatus=currentStatus;
-                }else  if(lastStatus!=currentStatus)
-                {
-
-                    //如果添加了状态值,状态值变化存储,并清空
-                    if(oldStatusMap.containsKey(windturbineId))
-                    {
-
-                        //获取数据库中的状态值,状态值变化存储,并清空
-                        item=oldStatusMap.get(windturbineId);
-                        if(item==null)
-                        {
-                            item=new ProEconWindturbineStatus();
-                            initalWindturbineStatus(windturbineId, item, currentStatus, currentTime,stpo);
-                            oldStatusMap.put(windturbineId,item);
-                        }else
-                        {
-                            finishWindturbineStatus(windturbineId, item, currentStatus, currentTime);
-                            item =null;
-                            oldStatusMap.put(windturbineId,null);
-                        }
-
-
-
-                    }
-
-
-                    if(oldShutdownEvent.containsKey(windturbineId))
-                    {
-                        shutdwonEvent=oldShutdownEvent.get(windturbineId);
-
-                        if(shutdwonEvent==null)
-                        {
-                            shutdwonEvent=new ProEconShutdownEvent();
-                            initalShutdownEvent(windturbineId, item, currentStatus, currentTime, shutdwonEvent);
-                            oldShutdownEvent.put(windturbineId,shutdwonEvent);
-                        }else
-                        {
-                            shutdwonEvent = finishShutdownEvent(windturbineId, shutdwonEvent, currentStatus, currentTime);
-                            oldShutdownEvent.put(windturbineId,null);
-                        }
-
-
-                    }
-                    if(oldInterrup.containsKey(windturbineId))
-                    {
-                        interrup=oldInterrup.get(windturbineId);
-                        if(interrup==null)
-                        {
-                            interrup=new ProEconInterruption();
-                            initalInterruption(windturbineId, item, currentTime, interrup);
-                            oldInterrup.put(windturbineId,interrup);
-                        }else
-                        {
-                            interrup = finishInterruption(windturbineId, interrup, currentStatus, currentTime);
-                            oldInterrup.put(windturbineId,null);
-                        }
-
+//            try {
+//                Thread.sleep(100);
+//            } catch (InterruptedException e1) {
+//                e1.printStackTrace();
+//            }
+            new Thread(new ShutdownnewThread(executor,  oldStatusMap,  statusMap,  windturbineId,
+                     statusDescriptionMap,  oldShutdownEvent,
+                    oldInterrup,  oldShutdownEvent2,begin,  end,edosUtil,proEconWindturbineStatusService,
+                    proEconShutdownEventService, proEconShutdownEvent2Service,
+                    proEconInterruptionService)).start();
 
-                    }
-
-                    if(oldShutdownEvent2.containsKey(windturbineId))
-                    {
-                        shutdwonEvent2=oldShutdownEvent2.get(windturbineId);
-                        if(shutdwonEvent2==null)
-                        {
-                            shutdwonEvent2=new ProEconShutdownEvent2();
-                            initalShutdownEvent2(windturbineId, item, currentStatus, currentTime, shutdwonEvent2);
-                            oldShutdownEvent2.put(windturbineId,shutdwonEvent2);
-                        }else
-                        {
-                            shutdwonEvent2 = finishShutdownEvent2(windturbineId, shutdwonEvent2, currentStatus, currentTime);
-                            oldShutdownEvent2.put(windturbineId,null);
-                        }
-
-                    }
-
-                    lastStatus=currentStatus;
-                }
 
+        }
 
 
-            }
-            //循环结束落盘,并清空
-            if(oldStatusMap.containsKey(windturbineId))
-            {
-                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
-                item=oldStatusMap.get(windturbineId);
-                if(item!=null)
-                {
-                    ProEconWindturbineStatus finalItem = item;
-                    QueryWrapper<ProEconWindturbineStatus> queryWrapper9 = new QueryWrapper<>();
-                    queryWrapper9.eq("stop_Time",finalItem.getStopTime()).eq("windturbine_id",finalItem.getWindturbineId());
-                    List<ProEconWindturbineStatus> ls= proEconWindturbineStatusService.list(queryWrapper9);
-//                            .stream().filter(i->i.getWindturbineId().equals(finalItem.getWindturbineId())
-//                                    && i.getStopTime().compareTo(finalItem.getStopTime())==0).collect(Collectors.toList());
-
-                    if(ls.isEmpty())
-                    {
-                        proEconWindturbineStatusService.save(item);
-                        oldStatusMap.put(windturbineId,null);
-                    }
-                }
-
-
-            }
-
-
-            if(oldShutdownEvent.containsKey(windturbineId))
-            {
-
-                shutdwonEvent=oldShutdownEvent.get(windturbineId);
-
-                if(shutdwonEvent!=null)
-                {
-                    ProEconShutdownEvent finalShutdwonEvent = shutdwonEvent;
-                    QueryWrapper<ProEconShutdownEvent> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("stop_Time",finalShutdwonEvent.getStopTime()).eq("windturbine_id",finalShutdwonEvent.getWindturbineId());
-                    List<ProEconShutdownEvent> ls= proEconShutdownEventService.list(queryWrapper5);
-//                            .stream().filter(i->i.getWindturbineId().equals(finalShutdwonEvent.getWindturbineId())
-//                                    && i.getStopTime().compareTo(finalShutdwonEvent.getStopTime())==0)
-//                            .collect(Collectors.toList());
-
-                    if(ls.isEmpty())
-                    {
-                        proEconShutdownEventService.save(shutdwonEvent);
-                        oldShutdownEvent.put(windturbineId,null);
-                    }
-                }
-
-            }
-            if(oldInterrup.containsKey(windturbineId))
-            {
-
-                interrup=oldInterrup.get(windturbineId);
-
-                if(interrup!=null)
-                {
-                    ProEconInterruption finalInterrup = interrup;
-                    QueryWrapper<ProEconInterruption> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("stop_Time",finalInterrup.getStopTime()).eq("windturbine_id",finalInterrup.getWindturbineId());
-                    List<ProEconInterruption> ls= proEconInterruptionService.list(queryWrapper5);
-//                            .stream().filter(i->i.getWindturbineId().equals(finalInterrup.getWindturbineId())
-//                                    && i.getStopTime().compareTo(finalInterrup.getStopTime())==0).collect(Collectors.toList());
-
-                    if(ls.isEmpty())
-                    {
-                        proEconInterruptionService.save(interrup);
-                        oldInterrup.put(windturbineId,null);
-                    }
-                }
-
-
-            }
-
-            if(oldShutdownEvent2.containsKey(windturbineId))
-            {
-                shutdwonEvent2=oldShutdownEvent2.get(windturbineId);
-
-                if(shutdwonEvent2!=null)
-                {
-                    ProEconShutdownEvent2 finalShutdwonEvent1 = shutdwonEvent2;
-                    QueryWrapper<ProEconShutdownEvent2> queryWrapper5 = new QueryWrapper<>();
-                    queryWrapper5.eq("stop_Time",finalShutdwonEvent1.getStopTime()).eq("windturbine_id",finalShutdwonEvent1.getWindturbineId());
-                    List<ProEconShutdownEvent2> ls= proEconShutdownEvent2Service.list(queryWrapper5);
-//                            .stream().filter(i->i.getWindturbineId().equals(finalShutdwonEvent1.getWindturbineId())
-//                                    && i.getStopTime().compareTo(finalShutdwonEvent1.getStopTime())==0).collect(Collectors.toList());
-
-                    if(ls.isEmpty())
-                    {
-                        proEconShutdownEvent2Service.save(shutdwonEvent2);
-                        oldShutdownEvent2.put(windturbineId,null);
-                    }
-                }
-
-            }
-
-        }
 
 //******************************************************************************************************/
 

+ 3 - 6
realtime/generationXK-service/src/main/java/com/gyee/generation/service/TimelinessRateService.java

@@ -46,11 +46,8 @@ public class TimelinessRateService {
 
         Map<Date, Map<String, ProEconFaultLiminatedefects>> dtDictionary = new HashMap<>();
         Calendar c = Calendar.getInstance();
-        c.setTime(recordDate);
-        //Date now = Date.Now.Date.AddMonths(-1); //上月
-        Date now = DateUtils.truncate(c.getTime()); //本月
+        c.setTime(DateUtils.truncate(recordDate));//本月
 
-        c.setTime(now);
         c.set(Calendar.DAY_OF_MONTH, 1);
         Date begin = c.getTime();
 
@@ -59,7 +56,7 @@ public class TimelinessRateService {
         Date end = c.getTime();
 
         QueryWrapper<ProEconFaultLiminatedefects> queryWrapper = new QueryWrapper<>();
-        queryWrapper.ge("record_date",recordDate).le("record_date",recordDate);
+        queryWrapper.ge("date_time",recordDate).le("date_time",recordDate);
         List<Long> deleteitems = proEconFaultLiminatedefectsService.list(queryWrapper)
                 .stream()
 //                .filter(i ->
@@ -72,7 +69,7 @@ public class TimelinessRateService {
             proEconFaultLiminatedefectsService.removeByIds(deleteitems);
         }
         QueryWrapper<ProEconShutdownEvent> queryWrapper2 = new QueryWrapper<>();
-        queryWrapper2.ge("stop_Time",recordDate).le("stop_Time",recordDate);
+        queryWrapper2.ge("stop_Time",begin).le("stop_Time",end);
         List<ProEconShutdownEvent> st2 = proEconShutdownEventService.list(queryWrapper2);
 //                .stream()
 //                .filter(i ->

+ 23 - 84
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java

@@ -3,17 +3,18 @@ package com.gyee.generation.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.generation.init.CacheContext;
-import com.gyee.generation.model.auto.ProBasicEquipment;
 import com.gyee.generation.model.auto.ProEconEquipmentInfoDay1;
 import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
-import com.gyee.generation.model.vo.WpType;
 import com.gyee.generation.service.auto.IProEconEquipmentInfoDay1Service;
 import com.gyee.generation.service.auto.IProEconWindturbineGoodnessService;
+import com.gyee.generation.task.GoodnessOfFitThread;
 import com.gyee.generation.util.DateUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
 import java.util.stream.Collectors;
 
 @Service
@@ -30,6 +31,8 @@ public class WindturbineGoodnessService {
     private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
 
 
+    @Resource
+    private Executor executor;
     public void calWindturbineGoodness(Date recordDate) throws Exception {
 
 
@@ -50,97 +53,33 @@ public class WindturbineGoodnessService {
         }
 
 
+        QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.eq("record_date",DateUtils.truncate(recordDate));
+        List<ProEconEquipmentInfoDay1> ed1ls=  proEconEquipmentInfoDay1Service.list(queryWrapper2);
 
-        List<ProEconWindturbineGoodness> vos=new ArrayList<>();
+        Map<String,ProEconEquipmentInfoDay1> equipmentInfoDay1Map=new HashMap<>();
 
-        System.out.println("拟合优度风机数量"+CacheContext.wtls.size());
-        for(ProBasicEquipment wt: CacheContext.wtls)
+        if(!ed1ls.isEmpty())
         {
-            Map<String, Map<String, Double>> coefficientMap=new HashMap<>();
-            Map<String, Map<String,Double>> fitMap=new HashMap<>();
-            try {
-               coefficientMap=coefficientService.coefficient(wt.getId(),DateUtils.truncate(recordDate));
-               fitMap=goodnessOfFitService.goodnessOfFit(wt.getId(),DateUtils.truncate(recordDate));
-            }catch (Exception e)
-            {
-                System.out.println(e.getMessage());
-            }
-
-
-            QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
-            queryWrapper2.eq("windturbine_id",wt.getId());
-          List<ProEconEquipmentInfoDay1> day1ls=  proEconEquipmentInfoDay1Service.list(queryWrapper2).stream().filter(i->
-                    i.getWindturbineId().equals(wt.getId())
-            && i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
-            ).collect(Collectors.toList());
-
-            ProEconWindturbineGoodness po=new ProEconWindturbineGoodness();
-            po.setModelId(wt.getModelId());
-            po.setWindturbineId(wt.getId());
-            po.setRecordDate(DateUtils.truncate(recordDate));
-            po.setWindtpowerstationId(wt.getWindpowerstationId());
-            po.setCompanyId(wt.getCompanyId());
-            po.setRegionId(wt.getRegionId());
-            if(wt.getWindpowerstationId().contains(WpType.FDC.id))
-            {
-                po.setTypes("-1");
-            }else
-            {
-                po.setTypes("-2");
-            }
-            po.setDayGoodness(0.0);
-            po.setYearGoodness(0.0);
-            po.setMonthGoodness(0.0);
-            po.setDayCoefficient(0.0);
-            po.setMonthCoefficient(0.0);
-            po.setYearCoefficient(0.0);
-            po.setDaySpeed(0.0);
-            po.setMonthSpeed(0.0);
-            po.setYearSpeed(0.0);
-
-            if(!day1ls.isEmpty())
-            {
-                po.setDaySpeed(day1ls.get(0).getRpjfs());
-                po.setMonthSpeed(day1ls.get(0).getYpjfs());
-                po.setYearSpeed(day1ls.get(0).getYpjfs());
-            }else
+            for(ProEconEquipmentInfoDay1 ed1:ed1ls)
             {
-                po.setDaySpeed(0.0);
-                po.setMonthSpeed(0.0);
-                po.setYearSpeed(0.0);
+                equipmentInfoDay1Map.put(ed1.getWindturbineId(),ed1);
             }
+        }
+        List<ProEconWindturbineGoodness> vos=new ArrayList<>();
 
-            if(fitMap.containsKey(wt.getId()))
-            {
-                Map<String, Double> map=fitMap.get(wt.getId());
-                po.setDayGoodness(map.get("day"));
-                po.setYearGoodness(map.get("month"));
-                po.setMonthGoodness(map.get("year"));
-            }else
-            {
-                po.setDayGoodness(0.0);
-                po.setYearGoodness(0.0);
-                po.setMonthGoodness(0.0);
-            }
-
-            if(coefficientMap.containsKey(wt.getId()))
-            {
-                Map<String, Double> map=coefficientMap.get(wt.getId());
-                po.setDayCoefficient(map.get("day"));
-                po.setMonthCoefficient(map.get("month"));
-                po.setMonthCoefficient(map.get("year"));
-            }else
-            {
-
-                po.setDayCoefficient(0.0);
-                po.setMonthCoefficient(0.0);
-                po.setMonthCoefficient(0.0);
-            }
+        System.out.println("拟合优度风机数量"+CacheContext.wtls.size());
 
+        final CountDownLatch latch = new CountDownLatch(+CacheContext.wtls.size());
+        for(int i=0;i<CacheContext.wtls.size();i++)
+        {
+            new Thread(new GoodnessOfFitThread(executor, i,  recordDate,  coefficientService,
+                    goodnessOfFitService,
+                    equipmentInfoDay1Map,  vos,latch)).start();
 
-            vos.add(po);
-           // proEconWindturbineGoodnessService.save(po);
+            // proEconWindturbineGoodnessService.save(po);
         }
+        latch.await();
         vos.sort(new Comparator<ProEconWindturbineGoodness>() {
             @Override
             public int compare(ProEconWindturbineGoodness o1, ProEconWindturbineGoodness o2) {

+ 1 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtwindDayInfoService.java

@@ -844,7 +844,7 @@ public class WtwindDayInfoService {
 
             //日静风频次
             if (es_dayfcs != 0) {
-                pewp.setSe6(BigDecimal.valueOf(ees_dayjfcs).divide(new BigDecimal(ees_dayfcs), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
+                pewp.setSe6(BigDecimal.valueOf(es_dayjfcs).divide(new BigDecimal(es_dayfcs), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
             }
         }
 //*******************************************************************************************************************/

+ 101 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/BrownoutsThread.java

@@ -0,0 +1,101 @@
+package com.gyee.generation.task;
+
+import com.gyee.common.model.PointData;
+import com.gyee.generation.model.auto.ProEconBrownoutsEvent;
+import com.gyee.generation.model.auto.ProEconBrownoutsEvent2;
+import com.gyee.generation.model.auto.ProEconMainBrownouts;
+import com.gyee.generation.model.auto.ProEconMainBrownouts2;
+import com.gyee.generation.service.auto.IProEconBrownoutsEvent2Service;
+import com.gyee.generation.service.auto.IProEconBrownoutsEventService;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
+
+public class BrownoutsThread implements Runnable {
+
+	private  Logger logger = LoggerFactory.getLogger(this.getClass());
+	private Executor executor;
+
+	private Map<String, List<PointData>> statusMap;
+
+	private String wtId;
+	private Map<String, ProEconBrownoutsEvent> oldBrownoutsStatusMap;
+
+	private Map<String, ProEconBrownoutsEvent2> oldBrownoutsStatus2Map;
+
+	private IProEconBrownoutsEventService proEconBrownoutsEventService;
+
+	private IProEconBrownoutsEvent2Service proEconBrownoutsEvent2Service;
+
+	private Map<Integer, String> statusDescriptionMap;
+
+	private Map<String, Map<String, ProEconMainBrownouts2>> newMainBrownouts2Map;
+	private Map<String, Map<String, ProEconMainBrownouts>> newMainBrownoutsMap;
+	private IEdosUtil edosUtil;
+	private Date begin;
+	private Date end;
+
+	public BrownoutsThread(Executor executor,
+						   Map<String, List<PointData>> statusMap, String wtId,
+						   Map<String, ProEconBrownoutsEvent> oldBrownoutsStatusMap,
+						   Map<String, ProEconBrownoutsEvent2> oldBrownoutsStatus2Map,
+						   IProEconBrownoutsEventService proEconBrownoutsEventService,
+						   IProEconBrownoutsEvent2Service proEconBrownoutsEvent2Service,
+						   Map<Integer, String> statusDescriptionMap,
+						   Map<String, Map<String, ProEconMainBrownouts2>> newMainBrownouts2Map,
+						   Map<String, Map<String, ProEconMainBrownouts>> newMainBrownoutsMap,
+						   IEdosUtil edosUtil, Date begin, Date end
+
+						   ) {
+		this.executor = executor;
+		this.statusMap = statusMap;
+		this.wtId = wtId;
+		this.oldBrownoutsStatusMap = oldBrownoutsStatusMap;
+		this.oldBrownoutsStatus2Map = oldBrownoutsStatus2Map;
+		this.proEconBrownoutsEventService = proEconBrownoutsEventService;
+		this.proEconBrownoutsEvent2Service = proEconBrownoutsEvent2Service;
+		this.statusDescriptionMap = statusDescriptionMap;
+		this.newMainBrownoutsMap = newMainBrownoutsMap;
+		this.newMainBrownouts2Map = newMainBrownouts2Map;
+		this.begin = begin;
+		this.end = end;
+		this.edosUtil = edosUtil;
+	}
+
+	@Override
+	public synchronized void run() {
+
+		String task = "task@ " + wtId;
+		logger.info("限电子表数据创建任务并提交到线程池中:" + wtId);
+		FutureTask<String> futureTask = new FutureTask<String>(new BrownoutsThreadPool(task,
+				statusMap,  wtId, oldBrownoutsStatusMap,oldBrownoutsStatus2Map,
+				 proEconBrownoutsEventService,
+				 proEconBrownoutsEvent2Service,
+				statusDescriptionMap,
+				newMainBrownouts2Map,
+				 newMainBrownoutsMap,
+				 edosUtil,  begin,  end
+					));
+		executor.execute(futureTask);
+		// 在这里可以做别的任何事情
+		String result = null;
+		try {
+			// 取得结果,同时设置超时执行时间为1秒。同样可以用future.get(),不设置执行超时时间取得结果
+			result = futureTask.get();
+		} catch (InterruptedException e) {
+			futureTask.cancel(true);
+		} catch (ExecutionException e) {
+			futureTask.cancel(true);
+		} catch (Exception e) {
+			futureTask.cancel(true);
+			// 超时后,进行相应处理
+		} 
+	}
+}

+ 549 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/BrownoutsThreadPool.java

@@ -0,0 +1,549 @@
+package com.gyee.generation.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.*;
+import com.gyee.generation.model.vo.StatData;
+import com.gyee.generation.service.auto.IProEconBrownoutsEvent2Service;
+import com.gyee.generation.service.auto.IProEconBrownoutsEventService;
+import com.gyee.generation.util.DateUtils;
+import com.gyee.generation.util.StringUtils;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+public class BrownoutsThreadPool implements Callable<String>, Serializable {
+
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private static final long serialVersionUID = 0;
+
+    // 保存任务所需要的数据
+
+    private Object threadPoolTaskData;
+    private Map<String, List<PointData>> statusMap;
+
+    private String wtId;
+    private Map<String, ProEconBrownoutsEvent> oldBrownoutsStatusMap;
+
+    private Map<String, ProEconBrownoutsEvent2> oldBrownoutsStatus2Map;
+
+    private IProEconBrownoutsEventService proEconBrownoutsEventService;
+
+    private IProEconBrownoutsEvent2Service proEconBrownoutsEvent2Service;
+
+    private Map<Integer, String> statusDescriptionMap;
+
+    private Map<String, Map<String, ProEconMainBrownouts2>> newMainBrownouts2Map;
+    private Map<String, Map<String, ProEconMainBrownouts>> newMainBrownoutsMap;
+    private IEdosUtil edosUtil;
+    private Date begin;
+    private Date end;
+
+
+    public BrownoutsThreadPool(Object tasks,
+                               Map<String, List<PointData>> statusMap, String wtId,
+                               Map<String, ProEconBrownoutsEvent> oldBrownoutsStatusMap,
+                               Map<String, ProEconBrownoutsEvent2> oldBrownoutsStatus2Map,
+                               IProEconBrownoutsEventService proEconBrownoutsEventService,
+                               IProEconBrownoutsEvent2Service proEconBrownoutsEvent2Service,
+                               Map<Integer, String> statusDescriptionMap,
+                               Map<String, Map<String, ProEconMainBrownouts2>> newMainBrownouts2Map,
+                               Map<String, Map<String, ProEconMainBrownouts>> newMainBrownoutsMap,
+                               IEdosUtil edosUtil, Date begin, Date end
+
+    ) {
+
+        this.threadPoolTaskData = tasks;
+        this.statusMap = statusMap;
+        this.wtId = wtId;
+        this.oldBrownoutsStatusMap = oldBrownoutsStatusMap;
+        this.oldBrownoutsStatus2Map = oldBrownoutsStatus2Map;
+        this.proEconBrownoutsEventService = proEconBrownoutsEventService;
+        this.proEconBrownoutsEvent2Service = proEconBrownoutsEvent2Service;
+        this.statusDescriptionMap = statusDescriptionMap;
+        this.newMainBrownoutsMap = newMainBrownoutsMap;
+        this.newMainBrownouts2Map = newMainBrownouts2Map;
+        this.begin = begin;
+        this.end = end;
+        this.edosUtil = edosUtil;
+
+
+    }
+
+    public synchronized String call() throws Exception {
+
+
+        // 处理一个任务,这里的处理方式太简单了,仅仅是一个打印语句
+
+        //System.out.println("开始执行任务:" + threadPoolTaskData);
+
+        String result = "";
+
+        // //便于观察,等待一段时间
+
+
+        try {
+
+
+          Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wtId);
+
+            //取实时状态数据 赋值给status
+
+            if (windturbinetestingpointnewMap.containsKey(ContantXk.MXZT)) {
+                ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
+                //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+                List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000, null, 1L);
+                statusMap.put(wtId, statusls);
+            }
+
+            List<ProEconBrownoutsEvent2> proEconBrownoutsEvent2ls=new ArrayList<>();
+            List<ProEconBrownoutsEvent> proEconBrownoutsEventls=new ArrayList<>();
+
+
+
+
+            ProEconBrownoutsEvent brownoutsEvent = null;
+            ProEconBrownoutsEvent2 brownoutsEvent2;
+            //获取5分钟的状态值
+            List<PointData> statusls = statusMap.get(wtId);
+
+            Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wtId);
+            //记录上次判定的状态值
+            int lastStatus = (int) statusls.get(0).getPointValueInDouble();
+            for (PointData stpo : statusls) {
+                //获取当前状态
+                int currentStatus = (int) stpo.getPointValueInDouble();
+                //获取当前时间
+                Date currentTime = new Date(stpo.getPointTime());
+                //如果数据库中不存在该风机未完成的故障记录,进入
+                if (brownoutsEvent == null) {
+                    if (currentStatus == 8 || currentStatus == 9) {
+                        brownoutsEvent = new ProEconBrownoutsEvent();
+                        initialBrownoutsEvent(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent);
+                        oldBrownoutsStatusMap.put(wtId, brownoutsEvent);
+
+                        brownoutsEvent2 = new ProEconBrownoutsEvent2();
+                        initialBrownoutsEvent2(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent2);
+                        oldBrownoutsStatus2Map.put(wtId, brownoutsEvent2);
+                    }
+
+
+                    //将当前状态赋值给过去状态
+                    lastStatus = currentStatus;
+                } else if (lastStatus != currentStatus) {
+
+                    //如果添加了状态值,状态值变化存储,并清空
+                    if (oldBrownoutsStatusMap.containsKey(wtId)) {
+
+                        //获取数据库中的状态值,状态值变化存储,并清空
+                        brownoutsEvent = oldBrownoutsStatusMap.get(wtId);
+                        if (brownoutsEvent == null) {
+                            brownoutsEvent = new ProEconBrownoutsEvent();
+                            initialBrownoutsEvent(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent);
+                            oldBrownoutsStatusMap.put(wtId, brownoutsEvent);
+                        } else {
+                            finishBrownoutsEvent(wtId, brownoutsEvent, currentTime);
+                            oldBrownoutsStatusMap.put(wtId, null);
+                            brownoutsEvent = null;
+                        }
+
+
+                    }
+
+                    if (oldBrownoutsStatus2Map.containsKey(wtId)) {
+
+                        //获取数据库中的状态值,状态值变化存储,并清空
+                        brownoutsEvent2 = oldBrownoutsStatus2Map.get(wtId);
+                        if (brownoutsEvent2 == null) {
+                            brownoutsEvent2 = new ProEconBrownoutsEvent2();
+                            initialBrownoutsEvent2(wtId, wtpointmap, currentStatus, currentTime, brownoutsEvent2);
+                            oldBrownoutsStatus2Map.put(wtId, brownoutsEvent2);
+                        } else {
+                            finishBrownoutsEvent2(wtId, brownoutsEvent2, currentTime);
+                            oldBrownoutsStatus2Map.put(wtId, null);
+                        }
+
+
+                    }
+
+
+                    lastStatus = currentStatus;
+                }
+
+
+            }
+            //循环结束落盘,并清空
+            if (oldBrownoutsStatusMap.containsKey(wtId)) {
+                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
+                brownoutsEvent = oldBrownoutsStatusMap.get(wtId);
+                if (brownoutsEvent != null) {
+                    ProEconBrownoutsEvent finalItem = brownoutsEvent;
+                    QueryWrapper<ProEconBrownoutsEvent> queryWrapper5 = new QueryWrapper<>();
+                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
+                    List<ProEconBrownoutsEvent> ls = proEconBrownoutsEventService.list(queryWrapper5);
+//                            .stream().filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
+//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0).collect(Collectors.toList());
+
+                    if (ls.isEmpty()) {
+                        proEconBrownoutsEventService.save(finalItem);
+                        oldBrownoutsStatusMap.put(wtId, null);
+
+                    }
+                }
+
+
+            }
+
+
+            if (oldBrownoutsStatus2Map.containsKey(wtId)) {
+                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
+                brownoutsEvent2 = oldBrownoutsStatus2Map.get(wtId);
+                if (brownoutsEvent2 != null) {
+                    ProEconBrownoutsEvent2 finalItem = brownoutsEvent2;
+                    QueryWrapper<ProEconBrownoutsEvent2> queryWrapper5 = new QueryWrapper<>();
+                    queryWrapper5.eq("windpowerstation_id", finalItem.getWindpowerstationId()).eq("stop_Time",finalItem.getStopTime());
+                    List<ProEconBrownoutsEvent2> ls = proEconBrownoutsEvent2Service.list(queryWrapper5);
+//                            .stream().filter(i -> i.getWindpowerstationId().equals(finalItem.getWindpowerstationId())
+//                                    && i.getStopTime().compareTo(finalItem.getStopTime()) == 0).collect(Collectors.toList());
+
+                    if (ls.isEmpty()) {
+                        proEconBrownoutsEvent2Service.save(finalItem);
+                        oldBrownoutsStatus2Map.put(wtId, null);
+
+                    }
+                }
+
+            }
+
+
+            proEconBrownoutsEventService.saveOrUpdateBatch(proEconBrownoutsEventls);
+            proEconBrownoutsEvent2Service.saveOrUpdateBatch(proEconBrownoutsEvent2ls);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        threadPoolTaskData = null;
+
+        return result;
+
+    }
+    private void initialBrownoutsEvent(String wtId, Map<String, ProBasicEquipmentPoint> wtpointmap, Integer currentStatus, Date currentTime, ProEconBrownoutsEvent sub) throws Exception {
+        ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
+        Map<String, ProEconMainBrownouts> timemap = null;
+        if (newMainBrownoutsMap.containsKey(wt.getWindpowerstationId())) {
+            timemap = newMainBrownoutsMap.get(wt.getWindpowerstationId());
+        } else {
+            timemap = new HashMap<>();
+            newMainBrownoutsMap.put(wt.getWindpowerstationId(), timemap);
+        }
+        if (timemap.containsKey(String.valueOf(currentTime))) {
+            ProEconMainBrownouts mainObj = timemap.get(String.valueOf(currentTime));
+            sub.setMainId(mainObj.getId());
+        }
+
+
+        sub.setId(StringUtils.getUUID());
+        sub.setWindpowerstationId(wt.getWindpowerstationId());
+        sub.setWindturbineId(wt.getId());
+        sub.setProjectId(wt.getProjectId());
+        sub.setLineId(wt.getLineId());
+        sub.setStopTime(currentTime);
+        sub.setStartTime(null);
+        sub.setStopHours(0.0);
+        sub.setLossPower(0.0);
+
+        sub.setStopTypeId(statusDescriptionMap.get(currentStatus));
+
+
+        PointData data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSGL));
+        sub.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
+        data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSFS));
+        sub.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
+
+
+        long pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
+        List<PointData> hsls = edosUtil.getHistStat(wtpointmap.get(ContantXk.CJ_SSGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
+        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
+            sub.setThisLoad(hsls.get(0).getPointValueInDouble());
+
+
+            oldBrownoutsStatusMap.put(wtId, sub);
+        }
+
+    }
+
+    private void initialBrownoutsEvent2(String wtId, Map<String, ProBasicEquipmentPoint> wtpointmap, Integer currentStatus, Date currentTime, ProEconBrownoutsEvent2 sub) throws Exception {
+        ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
+        Map<String, ProEconMainBrownouts2> timemap = null;
+        if (newMainBrownouts2Map.containsKey(wt.getWindpowerstationId())) {
+            timemap = newMainBrownouts2Map.get(wt.getWindpowerstationId());
+
+        }else
+        {
+            timemap=new HashMap<>();
+            newMainBrownouts2Map.put(wt.getWindpowerstationId(),timemap);
+        }
+        if (timemap.containsKey(String.valueOf(currentTime))) {
+            ProEconMainBrownouts2 mainObj = timemap.get(String.valueOf(currentTime));
+            sub.setMainId(mainObj.getId());
+        }
+
+        sub.setId(StringUtils.getUUID());
+        sub.setWindpowerstationId(wt.getWindpowerstationId());
+        sub.setWindturbineId(wt.getId());
+        sub.setProjectId(wt.getProjectId());
+        sub.setLineId(wt.getLineId());
+        sub.setStopTime(currentTime);
+        sub.setStartTime(null);
+        sub.setStopHours(0.0);
+        sub.setLossPower(0.0);
+        sub.setStopTypeId(statusDescriptionMap.get(currentStatus));
+
+
+        PointData data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSGL));
+        sub.setLimitLoad(StringUtils.round(data.getPointValueInDouble(), 2));
+        data = edosUtil.getRealData(wtpointmap.get(ContantXk.CJ_SSFS));
+        sub.setWindSpeed(StringUtils.round(data.getPointValueInDouble(), 2));
+
+
+        long pried = DateUtils.secondsDiff(DateUtils.addMinutes(currentTime, -5), currentTime);
+        List<PointData> hsls = edosUtil.getHistStat(wtpointmap.get(ContantXk.CJ_SSGL), DateUtils.addMinutes(currentTime, -5).getTime() / 1000, currentTime.getTime() / 1000, 1L, pried, StatData.MAX.getValue());
+        if (StringUtils.notEmp(hsls) && hsls.size() > 0) {
+            sub.setThisLoad(hsls.get(0).getPointValueInDouble());
+
+        }
+
+        oldBrownoutsStatus2Map.put(wtId, sub);
+
+
+    }
+
+
+
+
+    private void finishBrownoutsEvent(String wpId, ProEconBrownoutsEvent item, Date currentTime) throws Exception {
+//        if (currentStatus != 8 && currentStatus != 9)
+//        {
+        item.setStartTime(currentTime);
+        double timehour = DateUtils.hoursDiff2(item.getStartTime(), item.getStopTime());
+        item.setStopHours(timehour);
+        double losspower = calLossPower(wpId, item.getStartTime(), item.getStopTime());
+        item.setLossPower(losspower);
+        proEconBrownoutsEventService.saveOrUpdate(item);
+
+
+        //       }
+    }
+
+    private void finishBrownoutsEvent2(String wpId, ProEconBrownoutsEvent2 brownoutsEvent2, Date currentTime) throws Exception {
+//        if (currentStatus != 8 && currentStatus != 9)
+//        {
+        brownoutsEvent2.setStartTime(currentTime);
+
+        double timehour = DateUtils.hoursDiff2(brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
+        brownoutsEvent2.setStopHours(timehour);
+        double losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
+        brownoutsEvent2.setLossPower(losspower);
+
+        if (timehour <= 24) {
+            proEconBrownoutsEvent2Service.saveOrUpdate(brownoutsEvent2);
+        } else {
+            int days = DateUtils.daysDiff1(brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
+            Calendar c = Calendar.getInstance();
+            Date startTime = brownoutsEvent2.getStartTime();
+            c.setTime(brownoutsEvent2.getStopTime());
+            c.set(Calendar.HOUR_OF_DAY, 23);
+            c.set(Calendar.MINUTE, 59);
+            c.set(Calendar.SECOND, 59);
+            for (int i = 0; i < days; i++) {
+                if (i == 0) {
+                    brownoutsEvent2.setStartTime(c.getTime());
+                    losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
+
+                } else {
+                    brownoutsEvent2.setStopTime(DateUtils.truncate(c.getTime()));
+                    if (i == days - 1) {
+                        brownoutsEvent2.setStartTime(startTime);
+
+                    } else {
+                        brownoutsEvent2.setStartTime(c.getTime());
+
+                    }
+                    losspower = calLossPower(wpId, brownoutsEvent2.getStartTime(), brownoutsEvent2.getStopTime());
+                }
+                brownoutsEvent2.setLossPower(losspower);
+                proEconBrownoutsEvent2Service.saveOrUpdate(brownoutsEvent2);
+
+
+                c.add(Calendar.DAY_OF_MONTH, 1);
+            }
+        }
+
+
+//        }
+
+    }
+
+
+
+    //修改后的限电损失统计,通过时序数据库历史切面计算
+    private Double calLossPower(String windturbineId, Date startDate, Date endDate) throws Exception {
+        double result = 0.0;
+
+        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+        Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
+
+        Calendar c1 = Calendar.getInstance();
+        c1.setTime(startDate);
+        Calendar c2 = Calendar.getInstance();
+        c2.setTime(endDate);
+        //判定限电是否跨年
+        if (endDate.after(startDate) && c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
+            //年限电欠发损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
+                double beginvalue;
+                double endvalue;
+
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
+                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
+
+
+                if (xdbegin.size() == 1 && xdend.size() == 1) {
+                    beginvalue = xdbegin.get(0).getPointValueInDouble();
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > beginvalue) {
+                        result = result + (endvalue - beginvalue);
+                    }
+                }
+            }
+
+            //年限电损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
+                double beginvalue;
+                double endvalue;
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
+                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
+
+
+                if (xdbegin.size() == 1 && xdend.size() == 1) {
+                    beginvalue = xdbegin.get(0).getPointValueInDouble();
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > beginvalue) {
+                        result = result + (endvalue - beginvalue);
+                    }
+                }
+            }
+        } else {
+            Calendar c = Calendar.getInstance();
+            c.setTime(DateUtils.truncate(startDate));
+            c.add(Calendar.DAY_OF_MONTH, 1);
+            //获得1月1日零点值
+            Date endtime = c.getTime();
+            //年限电欠发损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
+                double beginvalue;
+                double endvalue;
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
+                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
+
+
+                if (xdbegin.size() == 1 && xdend.size() == 1) {
+                    beginvalue = xdbegin.get(0).getPointValueInDouble();
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > beginvalue) {
+                        result = result + (endvalue - beginvalue);
+                    }
+                }
+            }
+
+            //年限电损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
+                double beginvalue;
+                double endvalue;
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
+                List<PointData> xdbegin = edosUtil.getHistMatrix(pointid, startDate.getTime() / 1000);
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endtime.getTime() / 1000);
+
+
+                if (xdbegin.size() == 1 && xdend.size() == 1) {
+                    beginvalue = xdbegin.get(0).getPointValueInDouble();
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > beginvalue) {
+                        result = result + (endvalue - beginvalue);
+                    }
+                }
+            }
+
+
+            //日限电欠发损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDTJSSDL)) {
+
+                double endvalue;
+
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
+
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
+
+
+                if (xdend.size() == 1) {
+
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > 0) {
+                        result = result + endvalue;
+                    }
+                }
+            }
+
+            //日限电损失电量
+            if (wtpointmap.containsKey(ContantXk.NXDJCLSSDL)) {
+
+                double endvalue;
+
+
+                List<String> pointid = new ArrayList<>();
+                pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
+
+                List<PointData> xdend = edosUtil.getHistMatrix(pointid, endDate.getTime() / 1000);
+
+
+                if (xdend.size() == 1) {
+
+                    endvalue = xdend.get(0).getPointValueInDouble();
+
+                    if (endvalue > 0) {
+                        result = result + endvalue;
+                    }
+                }
+            }
+        }
+
+
+        return result;
+
+    }
+}

+ 75 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/GoodnessOfFitThread.java

@@ -0,0 +1,75 @@
+package com.gyee.generation.task;
+
+import com.gyee.generation.model.auto.ProEconEquipmentInfoDay1;
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.gyee.generation.service.CoefficientService;
+import com.gyee.generation.service.GoodnessOfFitService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
+
+public class GoodnessOfFitThread implements Runnable {
+
+	private  Logger logger = LoggerFactory.getLogger(this.getClass());
+	private Executor executor;
+
+
+	private int i;
+	private  Date recordDate;
+
+	private CoefficientService coefficientService;
+	private GoodnessOfFitService goodnessOfFitService;
+
+	private Map<String,ProEconEquipmentInfoDay1> equipmentInfoDay1Map;
+	private List<ProEconWindturbineGoodness> vos;
+
+	private CountDownLatch latch;
+
+	public GoodnessOfFitThread(Executor executor, int i, Date recordDate, CoefficientService coefficientService,
+							   GoodnessOfFitService goodnessOfFitService,
+							   Map<String, ProEconEquipmentInfoDay1> equipmentInfoDay1Map, List<ProEconWindturbineGoodness> vos,
+							   CountDownLatch latch	) {
+		this.executor = executor;
+		this.i = i;
+		this.recordDate = recordDate;
+		this.coefficientService = coefficientService;
+		this.goodnessOfFitService = goodnessOfFitService;
+		this.equipmentInfoDay1Map = equipmentInfoDay1Map;
+		this.vos = vos;
+		this.latch = latch;
+	}
+
+	@Override
+	public synchronized void run() {
+
+		String task = "task@ " + i;
+		logger.info("功率一致性系数创建任务并提交到线程池中:" + i);
+		FutureTask<String> futureTask = new FutureTask<String>(new GoodnessOfFitThreadPool(task, i,  recordDate,  coefficientService,
+				 goodnessOfFitService,
+				 equipmentInfoDay1Map,  vos	));
+
+		executor.execute(futureTask);
+		// 在这里可以做别的任何事情
+		String result = null;
+		try {
+			// 取得结果,同时设置超时执行时间为1秒。同样可以用future.get(),不设置执行超时时间取得结果
+			result = futureTask.get();
+		} catch (InterruptedException e) {
+			futureTask.cancel(true);
+		} catch (ExecutionException e) {
+			futureTask.cancel(true);
+		} catch (Exception e) {
+			futureTask.cancel(true);
+			// 超时后,进行相应处理
+		}finally {
+			latch.countDown();
+		}
+	}
+}

+ 163 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/GoodnessOfFitThreadPool.java

@@ -0,0 +1,163 @@
+package com.gyee.generation.task;
+
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.ProBasicEquipment;
+import com.gyee.generation.model.auto.ProEconEquipmentInfoDay1;
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.gyee.generation.model.vo.WpType;
+import com.gyee.generation.service.CoefficientService;
+import com.gyee.generation.service.GoodnessOfFitService;
+import com.gyee.generation.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+public class GoodnessOfFitThreadPool implements Callable<String>, Serializable {
+
+	private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+	private static final long serialVersionUID = 0;
+
+	// 保存任务所需要的数据
+
+	private Object threadPoolTaskData;
+	private int i;
+	private  Date recordDate;
+
+	private CoefficientService coefficientService;
+	private GoodnessOfFitService goodnessOfFitService;
+
+	private Map<String,ProEconEquipmentInfoDay1> equipmentInfoDay1Map;
+	private List<ProEconWindturbineGoodness> vos;
+
+
+	public GoodnessOfFitThreadPool(Object tasks, int i, Date recordDate,CoefficientService coefficientService,
+								   GoodnessOfFitService goodnessOfFitService,
+								   Map<String,ProEconEquipmentInfoDay1> equipmentInfoDay1Map,List<ProEconWindturbineGoodness> vos
+	) {
+
+		this.threadPoolTaskData = tasks;
+		this.i = i;
+		this.recordDate = recordDate;
+		this.coefficientService = coefficientService;
+		this.goodnessOfFitService = goodnessOfFitService;
+		this.equipmentInfoDay1Map = equipmentInfoDay1Map;
+		this.vos = vos;
+
+	}
+
+	public synchronized String call() throws Exception {
+
+
+		// 处理一个任务,这里的处理方式太简单了,仅仅是一个打印语句
+
+		//System.out.println("开始执行任务:" + threadPoolTaskData);
+
+		String result = "";
+
+		// //便于观察,等待一段时间
+
+
+
+		try {
+
+			System.out.println("拟合优度当前风机数"+i);
+			ProBasicEquipment wt=CacheContext.wtls.get(i);
+			Map<String, Map<String, Double>> coefficientMap=new HashMap<>();
+			Map<String, Map<String,Double>> fitMap=new HashMap<>();
+			try {
+				coefficientMap=coefficientService.coefficient(wt.getId(),DateUtils.truncate(recordDate));
+				fitMap=goodnessOfFitService.goodnessOfFit(wt.getId(),DateUtils.truncate(recordDate));
+			}catch (Exception e)
+			{
+				System.out.println(e.getMessage());
+			}
+
+
+
+
+			ProEconWindturbineGoodness po=new ProEconWindturbineGoodness();
+			po.setModelId(wt.getModelId());
+			po.setWindturbineId(wt.getId());
+			po.setRecordDate(DateUtils.truncate(recordDate));
+			po.setWindtpowerstationId(wt.getWindpowerstationId());
+			po.setCompanyId(wt.getCompanyId());
+			po.setRegionId(wt.getRegionId());
+			if(wt.getWindpowerstationId().contains(WpType.FDC.id))
+			{
+				po.setTypes("-1");
+			}else
+			{
+				po.setTypes("-2");
+			}
+			po.setDayGoodness(0.0);
+			po.setYearGoodness(0.0);
+			po.setMonthGoodness(0.0);
+			po.setDayCoefficient(0.0);
+			po.setMonthCoefficient(0.0);
+			po.setYearCoefficient(0.0);
+			po.setDaySpeed(0.0);
+			po.setMonthSpeed(0.0);
+			po.setYearSpeed(0.0);
+
+			if(equipmentInfoDay1Map.containsKey(wt.getId()))
+			{
+				ProEconEquipmentInfoDay1 ed1=equipmentInfoDay1Map.get(wt.getId());
+				po.setDaySpeed(ed1.getRpjfs());
+				po.setMonthSpeed(ed1.getYpjfs());
+				po.setYearSpeed(ed1.getNpjfs());
+			}else
+			{
+				po.setDaySpeed(0.0);
+				po.setMonthSpeed(0.0);
+				po.setYearSpeed(0.0);
+			}
+
+			if(fitMap.containsKey(wt.getId()))
+			{
+				Map<String, Double> map=fitMap.get(wt.getId());
+				po.setDayGoodness(null!=map.get("day")?map.get("day"):0.0);
+				po.setYearGoodness(null!=map.get("month")?map.get("month"):0.0);
+				po.setMonthGoodness(null!=map.get("year")?map.get("year"):0.0);
+			}else
+			{
+				po.setDayGoodness(0.0);
+				po.setYearGoodness(0.0);
+				po.setMonthGoodness(0.0);
+			}
+
+			if(coefficientMap.containsKey(wt.getId()))
+			{
+				Map<String, Double> map=coefficientMap.get(wt.getId());
+				po.setDayCoefficient(null!=map.get("day")?map.get("day"):0.0);
+				po.setMonthCoefficient(null!=map.get("month")?map.get("month"):0.0);
+				po.setMonthCoefficient(null!=map.get("year")?map.get("year"):0.0);
+			}else
+			{
+
+				po.setDayCoefficient(0.0);
+				po.setMonthCoefficient(0.0);
+				po.setMonthCoefficient(0.0);
+			}
+
+
+			vos.add(po);
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		threadPoolTaskData = null;
+
+		return result;
+
+	}
+
+
+}

+ 191 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/InputOrOutPutThreadPool.java

@@ -0,0 +1,191 @@
+package com.gyee.generation.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.ProBasicEquipment;
+import com.gyee.generation.model.auto.ProBasicEquipmentPoint;
+import com.gyee.generation.model.auto.ProEconInputOrOutputSpeed;
+import com.gyee.generation.service.auto.IProEconInputOrOutputSpeedService;
+import com.gyee.generation.util.DateUtils;
+import com.gyee.generation.util.StringUtils;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+public class InputOrOutPutThreadPool implements Callable<String>, Serializable {
+
+	private Logger logger = LoggerFactory.getLogger(this.getClass());
+	
+	private static final long serialVersionUID = 0;
+	private String unicode4hour="JKYC001";
+	private String unicode1day="JKYC006";
+	private String unicode3day="JKYC011";
+	private String unicode7day="JKYC016";
+	private String unicode1month="JKYC021";
+	// 保存任务所需要的数据
+
+	private Object threadPoolTaskData;
+	private IEdosUtil edosUtil;
+	private ProBasicEquipment wt;
+	private Date begin;
+	private Date end;
+
+	private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
+
+	private static Map<String,Double> wtLastStatusMap=new HashMap<>();
+
+	private static  Map<String, ProEconInputOrOutputSpeed> wtTimeStatusMap=new HashMap<>();
+	public InputOrOutPutThreadPool(Object tasks, ProBasicEquipment wt,  Date begin, Date end,
+								   IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService,IEdosUtil edosUtil) {
+
+		this.threadPoolTaskData = tasks;
+		this.wt = wt;
+		this.begin = begin;
+		this.end = end;
+		this.proEconInputOrOutputSpeedService = proEconInputOrOutputSpeedService;
+		this.edosUtil = edosUtil;
+
+	}
+
+	public synchronized String call() throws Exception {
+
+		
+		// 处理一个任务,这里的处理方式太简单了,仅仅是一个打印语句
+
+		//System.out.println("开始执行任务:" + threadPoolTaskData);
+
+		String result = "";
+
+		// //便于观察,等待一段时间
+
+		
+
+		try {
+
+			Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getId());
+
+			QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
+			queryWrapper.ge("record_date",begin).le("record_date",end).eq("windturbine_id",wt.getId());
+			List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
+//            .stream()
+//                    .filter(i -> i.getWindturbineId().equals(wt.getId())
+//                            && (i.getRecordDate().compareTo(daybegin) == 0 || i.getRecordDate().after(daybegin))
+//                            && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
+//                           ).collect(Collectors.toList());
+
+			if(!recordList.isEmpty())
+			{
+				for(ProEconInputOrOutputSpeed po:recordList)
+				{
+					wtTimeStatusMap.put(String.valueOf(po.getRecordDate().getTime()),po);
+				}
+			}
+
+			double lastStatus=-1;
+
+
+			ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.SBZT);
+			ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
+
+			//获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+			List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxzt.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
+			List<PointData> ssfsls = edosUtil.getHistoryDatasSnap(ssfs.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
+
+
+			if(!statusls.isEmpty() && !ssfsls.isEmpty() && ssfsls.size()==statusls.size())
+			{
+				List<ProEconInputOrOutputSpeed> ls=new ArrayList<>();
+				for(int i=0;i<statusls.size();i++)
+				{
+
+
+					if(wtLastStatusMap.containsKey(wt.getId()))
+					{
+						lastStatus=wtLastStatusMap.get(wt.getId());
+					}
+
+					PointData statuspo=statusls.get(i);
+					PointData ssfspo=ssfsls.get(i);
+					double status= StringUtils.round(statuspo.getPointValueInDouble(),0);
+
+					if(i==0)
+					{
+						lastStatus=status;
+					}
+					if (!Objects.equals(lastStatus, status))
+					{
+
+						//     切入切出风速
+						if (lastStatus == 0 && status == 1)
+						{
+							ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
+
+							input.setWindturbineId(wt.getId());
+							input.setWindpowerstationId(wt.getWindpowerstationId());
+							input.setProjectId(wt.getProjectId());
+							input.setLineId(wt.getLineId());
+							input.setRecordDate(DateUtils.truncate(new Date(statuspo.getPointTime())));
+							input.setInputOrOutput(1);
+
+
+							input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
+
+							if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())))
+							{
+								//roEconInputOrOutputSpeedService.save(input);
+								ls.add(input);
+							}
+							lastStatus=status;
+
+						}
+						else if (lastStatus == 1 && status== 0)
+						{
+							ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
+							input.setWindturbineId(wt.getId());
+							input.setWindpowerstationId(wt.getWindpowerstationId());
+							input.setProjectId(wt.getProjectId());
+							input.setLineId(wt.getLineId());
+							input.setRecordDate(DateUtils.truncate(new Date(statuspo.getPointTime())));
+							input.setInputOrOutput(0);
+
+							input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
+
+							if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())))
+							{
+								//proEconInputOrOutputSpeedService.save(input);
+
+								ls.add(input);
+							}
+							lastStatus=status;
+						}
+
+						wtLastStatusMap.put(wt.getId(), status);
+
+					}
+				}
+
+
+				proEconInputOrOutputSpeedService.saveBatch(ls);
+
+
+			}
+
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		threadPoolTaskData = null;
+
+		return result;
+
+	}
+
+
+}

+ 58 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/InputOrOutPutkThread.java

@@ -0,0 +1,58 @@
+package com.gyee.generation.task;
+
+import com.gyee.generation.model.auto.ProBasicEquipment;
+import com.gyee.generation.service.auto.IProEconInputOrOutputSpeedService;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
+
+public class InputOrOutPutkThread implements Runnable {
+
+	private  Logger logger = LoggerFactory.getLogger(this.getClass());
+	private Executor executor;
+
+	private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
+	private IEdosUtil edosUtil;
+	private ProBasicEquipment wt;
+	private Date begin;
+	private Date end;
+
+
+
+	public InputOrOutPutkThread(Executor executor,  ProBasicEquipment wt,  Date begin, Date end,
+								IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService,IEdosUtil edosUtil) {
+		this.executor = executor;
+		this.wt = wt;
+		this.begin = begin;
+		this.end = end;
+		this.proEconInputOrOutputSpeedService = proEconInputOrOutputSpeedService;
+		this.edosUtil = edosUtil;
+	}
+
+	@Override
+	public synchronized void run() {
+
+		String task = "task@ " + wt.getId();
+		logger.info("风机切入切出数据创建任务并提交到线程池中:" + wt.getId());
+		FutureTask<String> futureTask = new FutureTask<String>(new InputOrOutPutThreadPool(task,wt,  begin, end,proEconInputOrOutputSpeedService, edosUtil));
+		executor.execute(futureTask);
+		// 在这里可以做别的任何事情
+		String result = null;
+		try {
+			// 取得结果,同时设置超时执行时间为1秒。同样可以用future.get(),不设置执行超时时间取得结果
+			result = futureTask.get();
+		} catch (InterruptedException e) {
+			futureTask.cancel(true);
+		} catch (ExecutionException e) {
+			futureTask.cancel(true);
+		} catch (Exception e) {
+			futureTask.cancel(true);
+			// 超时后,进行相应处理
+		} 
+	}
+}

Разница между файлами не показана из-за своего большого размера
+ 84 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/MainBrownoutsThread.java


Разница между файлами не показана из-за своего большого размера
+ 534 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/MainBrownoutsThreadPool.java


+ 54 - 46
realtime/generationXK-service/src/main/java/com/gyee/generation/task/SaticSchedulePgTask.java

@@ -101,27 +101,27 @@ public class SaticSchedulePgTask {
 
     //3.添加定时任务
     /**
-     * 切入切出统计
-     * 每分钟执行一次
+     * 15分钟数据统计
+     * 每15分钟执行一次
      */
 
     @XxlJob("calEquipmentInfo15minute_PG")
     public void calEquipmentInfo15minute_PG()  {
 
 
-        XxlJobHelper.log("切入切出状态切换记录调度程序执行开始!........");
+        XxlJobHelper.log("15分钟数据统计记录调度程序执行开始!........");
         try {
             equipmentInfo15minuteService.calEquipmentInfo15minute(new Date());
         } catch (Exception e) {
             e.printStackTrace();
         }
-        XxlJobHelper.log("切入切出状态切换记录调度任务处理完成!........");
+        XxlJobHelper.log("15分钟数据统计记录调度任务处理完成!........");
     }
 
     //3.添加定时任务
     /**
      * 切入切出统计
-     * 每分钟执行一次
+     * 每5分钟执行一次
      */
 
     @XxlJob("inputOrOutPutSpeed_PG")
@@ -140,7 +140,7 @@ public class SaticSchedulePgTask {
     //3.添加定时任务
     /**
      * 切入切出统计
-     * 每天执行一次
+     * 每天1点执行一次
      */
 
     @XxlJob("inputOrOutPut_PG")
@@ -158,7 +158,7 @@ public class SaticSchedulePgTask {
 
     /**
      * 停机记录
-     * 每15分钟执行一次
+     * 每5分钟执行一次
      */
     @XxlJob("shutdown_PG")
     public void shutdown_PG()  {
@@ -176,7 +176,7 @@ public class SaticSchedulePgTask {
 
     /**
      * 限电停机记录
-     * 每15分钟执行一次
+     * 每5分钟执行一次
      */
     @XxlJob("brownouts_PG")
     public void brownouts_PG()  {
@@ -396,29 +396,29 @@ public class SaticSchedulePgTask {
 
     }
 
-    /**
-     * 等级评估统计
-     * 每天执行一次
-     */
-
-    @XxlJob("equipmentInfoDayTop_PG")
-    public void equipmentInfoDayTop_PG()  {
-
-
-        XxlJobHelper.log("等级评估统计调度程序执行开始!........");
-        try {
-            equipmentInfoDayTopService.calEquipmentInfoDayTop(new Date());
-            equipmentInfoDayTopService.calEquipmentInfoMonthTop(new Date());
-            equipmentInfoDayTopService.calEquipmentInfoYearTop(new Date());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        XxlJobHelper.log("等级评估统计调度任务处理完成!........");
-    }
+//    /**
+//     * 等级评估统计
+//     * 每天执行一次
+//     */
+//
+//    @XxlJob("equipmentInfoDayTop_PG")
+//    public void equipmentInfoDayTop_PG()  {
+//
+//
+//        XxlJobHelper.log("等级评估统计调度程序执行开始!........");
+//        try {
+//            equipmentInfoDayTopService.calEquipmentInfoDayTop(new Date());
+//            equipmentInfoDayTopService.calEquipmentInfoMonthTop(new Date());
+//            equipmentInfoDayTopService.calEquipmentInfoYearTop(new Date());
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        XxlJobHelper.log("等级评估统计调度任务处理完成!........");
+//    }
 
     /**
      * 功率一致性系数和拟合优度
-     * 每天执行一次
+     * 每天2点执行一次
      */
 
     @XxlJob("windturbineGoodness_PG")
@@ -433,45 +433,53 @@ public class SaticSchedulePgTask {
         }
         XxlJobHelper.log("功率一致性系数和拟合优度统计调度任务处理完成!........");
     }
+//
+//
+//    @XxlJob("wtAlysisDay_PG")
+//    public void wtAlysisDay_PG()  {
+//
+//
+//        XxlJobHelper.log("分析数据统计调度程序执行开始!........");
+//        try {
+//            wtAlysisDayService.calEquipmentInfoDay(new Date());
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        XxlJobHelper.log("分析数据统计调度任务处理完成!........");
+//    }
 
-
-    @XxlJob("wtAlysisDay_PG")
-    public void wtAlysisDay_PG()  {
-
-
-        XxlJobHelper.log("分析数据统计调度程序执行开始!........");
-        try {
-            wtAlysisDayService.calEquipmentInfoDay(new Date());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        XxlJobHelper.log("分析数据统计调度任务处理完成!........");
-    }
-
+    /**
+     * 设备风资源统计调度
+     * 每天2点执行一次
+     */
     @XxlJob("wtwindDayInfo_PG")
     public void wtwindDayInfo_PG()  {
 
 
-        XxlJobHelper.log("设备数据统计调度程序执行开始!........");
+        XxlJobHelper.log("设备风资源统计调度程序执行开始!........");
         try {
             wpwindDayInfoService.calWpwindDayInfo(new Date());
         } catch (Exception e) {
             e.printStackTrace();
         }
-        XxlJobHelper.log("设备数据统计调度任务处理完成!........");
+        XxlJobHelper.log("设备风资源统计调度任务处理完成!........");
     }
 
+    /**
+     * 场站风资源统计调度
+     * 每天2点执行一次
+     */
     @XxlJob("wpwindDayInfo_PG")
     public void wpwindDayInfo_PG()  {
 
 
-        XxlJobHelper.log("设备数据统计调度程序执行开始!........");
+        XxlJobHelper.log("场站风资源统计调度程序执行开始!........");
         try {
             wtwindDayInfoService.calWtwindDayInfo(new Date());
         } catch (Exception e) {
             e.printStackTrace();
         }
-        XxlJobHelper.log("设备数据统计调度任务处理完成!........");
+        XxlJobHelper.log("场站风资源统计调度任务处理完成!........");
     }
 
     /**

+ 98 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/ShutdownnewThread.java

@@ -0,0 +1,98 @@
+package com.gyee.generation.task;
+
+import com.gyee.common.model.PointData;
+import com.gyee.generation.model.auto.ProEconInterruption;
+import com.gyee.generation.model.auto.ProEconShutdownEvent;
+import com.gyee.generation.model.auto.ProEconShutdownEvent2;
+import com.gyee.generation.model.auto.ProEconWindturbineStatus;
+import com.gyee.generation.service.auto.IProEconInterruptionService;
+import com.gyee.generation.service.auto.IProEconShutdownEvent2Service;
+import com.gyee.generation.service.auto.IProEconShutdownEventService;
+import com.gyee.generation.service.auto.IProEconWindturbineStatusService;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
+
+public class ShutdownnewThread implements Runnable {
+
+	private  Logger logger = LoggerFactory.getLogger(this.getClass());
+	private Executor executor;
+
+
+	private Map<String, ProEconWindturbineStatus> oldStatusMap;
+	private  Map<String, List<PointData>> statusMap;
+
+	private  String windturbineId;
+	private Map<Integer, String> statusDescriptionMap;
+
+	private Map<String, ProEconShutdownEvent> oldShutdownEvent;
+	private Map<String, ProEconInterruption> oldInterrup;
+	private Map<String, ProEconShutdownEvent2> oldShutdownEvent2;
+
+	private Date begin;
+	private  Date end;
+
+	private IEdosUtil edosUtil;
+	private IProEconWindturbineStatusService proEconWindturbineStatusService;
+	private IProEconShutdownEventService proEconShutdownEventService;
+	private IProEconShutdownEvent2Service proEconShutdownEvent2Service;
+	private IProEconInterruptionService proEconInterruptionService;
+
+	public ShutdownnewThread(Executor executor,  Map<String, ProEconWindturbineStatus> oldStatusMap, Map<String, List<PointData>> statusMap, String windturbineId,
+							 Map<Integer, String> statusDescriptionMap, Map<String, ProEconShutdownEvent> oldShutdownEvent,
+							 Map<String, ProEconInterruption> oldInterrup, Map<String, ProEconShutdownEvent2> oldShutdownEvent2,
+							 Date begin, Date end,
+							 IEdosUtil edosUtil,IProEconWindturbineStatusService proEconWindturbineStatusService,
+							 IProEconShutdownEventService proEconShutdownEventService,IProEconShutdownEvent2Service proEconShutdownEvent2Service,
+							 IProEconInterruptionService proEconInterruptionService	) {
+		this.executor = executor;
+		this.oldStatusMap = oldStatusMap;
+		this.statusMap = statusMap;
+		this.windturbineId = windturbineId;
+		this.statusDescriptionMap = statusDescriptionMap;
+		this.oldShutdownEvent = oldShutdownEvent;
+		this.oldInterrup = oldInterrup;
+		this.oldShutdownEvent2 = oldShutdownEvent2;
+		this.begin = begin;
+		this.end = end;
+
+		this.edosUtil = edosUtil;
+		this.proEconWindturbineStatusService = proEconWindturbineStatusService;
+		this.proEconShutdownEventService = proEconShutdownEventService;
+		this.proEconShutdownEvent2Service = proEconShutdownEvent2Service;
+		this.proEconInterruptionService = proEconInterruptionService;
+	}
+
+	@Override
+	public synchronized void run() {
+
+		String task = "task@ " + windturbineId;
+		logger.info("停机数据创建任务并提交到线程池中:" + windturbineId);
+		FutureTask<String> futureTask = new FutureTask<String>(new ShutdownnewThreadPool(task, oldStatusMap, statusMap, windturbineId,
+				 statusDescriptionMap,oldShutdownEvent,
+				oldInterrup, oldShutdownEvent2,  begin,  end,edosUtil,proEconWindturbineStatusService,
+				 proEconShutdownEventService, proEconShutdownEvent2Service,
+				 proEconInterruptionService	));
+		executor.execute(futureTask);
+		// 在这里可以做别的任何事情
+		String result = null;
+		try {
+			// 取得结果,同时设置超时执行时间为1秒。同样可以用future.get(),不设置执行超时时间取得结果
+			result = futureTask.get();
+		} catch (InterruptedException e) {
+			futureTask.cancel(true);
+		} catch (ExecutionException e) {
+			futureTask.cancel(true);
+		} catch (Exception e) {
+			futureTask.cancel(true);
+			// 超时后,进行相应处理
+		} 
+	}
+}

+ 667 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/task/ShutdownnewThreadPool.java

@@ -0,0 +1,667 @@
+package com.gyee.generation.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.PointData;
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.*;
+import com.gyee.generation.service.auto.IProEconInterruptionService;
+import com.gyee.generation.service.auto.IProEconShutdownEvent2Service;
+import com.gyee.generation.service.auto.IProEconShutdownEventService;
+import com.gyee.generation.service.auto.IProEconWindturbineStatusService;
+import com.gyee.generation.util.DateUtils;
+import com.gyee.generation.util.StringUtils;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+public class ShutdownnewThreadPool implements Callable<String>, Serializable {
+
+	private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+	private static final long serialVersionUID = 0;
+
+	// 保存任务所需要的数据
+
+	private Object threadPoolTaskData;
+	private Map<String, ProEconWindturbineStatus> oldStatusMap;
+	private  Map<String, List<PointData>> statusMap;
+
+	private  String windturbineId;
+	private Map<Integer, String> statusDescriptionMap;
+
+	private Map<String, ProEconShutdownEvent> oldShutdownEvent;
+	private Map<String, ProEconInterruption> oldInterrup;
+	private Map<String, ProEconShutdownEvent2> oldShutdownEvent2;
+	private  Date begin;
+	private  Date end;
+
+	private IEdosUtil edosUtil;
+	private IProEconWindturbineStatusService proEconWindturbineStatusService;
+	private IProEconShutdownEventService proEconShutdownEventService;
+	private IProEconShutdownEvent2Service proEconShutdownEvent2Service;
+	private IProEconInterruptionService proEconInterruptionService;
+
+	public ShutdownnewThreadPool(Object tasks,Map<String, ProEconWindturbineStatus> oldStatusMap,Map<String, List<PointData>> statusMap,String windturbineId,
+								   Map<Integer, String> statusDescriptionMap,Map<String, ProEconShutdownEvent> oldShutdownEvent,
+								   Map<String, ProEconInterruption> oldInterrup,
+								 Map<String, ProEconShutdownEvent2> oldShutdownEvent2, Date begin, Date end ,
+								 IEdosUtil edosUtil,IProEconWindturbineStatusService proEconWindturbineStatusService,
+								 IProEconShutdownEventService proEconShutdownEventService,IProEconShutdownEvent2Service proEconShutdownEvent2Service,
+								 IProEconInterruptionService proEconInterruptionService
+	) {
+
+		this.threadPoolTaskData = tasks;
+		this.oldStatusMap = oldStatusMap;
+		this.statusMap = statusMap;
+		this.windturbineId = windturbineId;
+		this.statusDescriptionMap = statusDescriptionMap;
+		this.oldShutdownEvent = oldShutdownEvent;
+		this.oldInterrup = oldInterrup;
+		this.oldShutdownEvent2 = oldShutdownEvent2;
+		this.begin = begin;
+		this.end = end;
+
+		this.edosUtil = edosUtil;
+		this.proEconWindturbineStatusService = proEconWindturbineStatusService;
+		this.proEconShutdownEventService = proEconShutdownEventService;
+		this.proEconShutdownEvent2Service = proEconShutdownEvent2Service;
+		this.proEconInterruptionService = proEconInterruptionService;
+	}
+
+	public synchronized String call() throws Exception {
+
+
+		// 处理一个任务,这里的处理方式太简单了,仅仅是一个打印语句
+
+		//System.out.println("开始执行任务:" + threadPoolTaskData);
+
+		String result = "";
+
+		// //便于观察,等待一段时间
+
+
+
+		try {
+
+
+			Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(windturbineId);
+
+			//取实时状态数据 赋值给status
+
+			if(windturbinetestingpointnewMap.containsKey(ContantXk.MXZT))
+			{
+				ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
+				//获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
+				List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxztPoint.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
+
+				statusMap.put(windturbineId, statusls);
+			}
+
+			ProEconWindturbineStatus item = oldStatusMap.get(windturbineId);
+			//获取5分钟的状态值
+			List<PointData> statusls=statusMap.get(windturbineId);
+
+			ProEconShutdownEvent shutdwonEvent=null;
+			ProEconInterruption interrup=null;
+			ProEconShutdownEvent2 shutdwonEvent2=null;
+			//记录上次判定的状态值
+			int lastStatus =(int)statusls.get(0).getPointValueInDouble();
+
+			List<ProEconShutdownEvent> shutdwonEventls=new ArrayList<>();
+			List<ProEconInterruption> interrupls=new ArrayList<>();
+			List<ProEconShutdownEvent2> shutdwonEvent2ls=new ArrayList<>();
+			List<ProEconWindturbineStatus> windturbineStatusls=new ArrayList<>();
+
+			for(PointData stpo:statusls)
+			{
+				//获取当前状态
+				Integer currentStatus = (int)stpo.getPointValueInDouble();
+				//获取当前时间
+				Date currentTime=new Date(stpo.getPointTime());
+				//如果数据库中不存在该风机未完成的故障记录,进入
+				if (item == null)
+				{
+
+					item = new ProEconWindturbineStatus();
+
+					initalWindturbineStatus(windturbineId, item, currentStatus, currentTime,stpo);
+
+					if (currentStatus == 4 || currentStatus == 6)
+					{
+						shutdwonEvent=new ProEconShutdownEvent();
+						initalShutdownEvent(windturbineId, item, currentStatus, currentTime, shutdwonEvent);
+
+
+						shutdwonEvent2=new ProEconShutdownEvent2();
+						initalShutdownEvent2(windturbineId, item, currentStatus, currentTime, shutdwonEvent2);
+
+
+						item.setShutdownEventId(shutdwonEvent.getId());
+					}
+					if (currentStatus == 12)
+					{
+						interrup=new ProEconInterruption();
+						initalInterruption(windturbineId, item, currentTime, interrup);
+					}
+
+					//将状态保存到MAP对象中
+					oldStatusMap.put(item.getWindturbineId(),item);
+
+
+					if (shutdwonEvent != null )
+					{
+						oldShutdownEvent.put(item.getWindturbineId(),shutdwonEvent);
+
+					}
+					if (interrup != null)
+					{
+						oldInterrup.put(item.getWindturbineId(),interrup);
+
+					}
+					if (shutdwonEvent2 != null)
+					{
+						oldShutdownEvent2.put(item.getWindturbineId(), shutdwonEvent2);
+					}
+					//将当前状态赋值给过去状态
+					lastStatus=currentStatus;
+				}else  if(lastStatus!=currentStatus)
+				{
+
+					//如果添加了状态值,状态值变化存储,并清空
+					if(oldStatusMap.containsKey(windturbineId))
+					{
+
+						//获取数据库中的状态值,状态值变化存储,并清空
+						item=oldStatusMap.get(windturbineId);
+						if(item==null)
+						{
+							item=new ProEconWindturbineStatus();
+							initalWindturbineStatus(windturbineId, item, currentStatus, currentTime,stpo);
+							oldStatusMap.put(windturbineId,item);
+						}else
+						{
+							finishWindturbineStatus(windturbineStatusls,windturbineId, item, currentStatus, currentTime);
+							item =null;
+							oldStatusMap.put(windturbineId,null);
+						}
+
+
+
+					}
+
+
+					if(oldShutdownEvent.containsKey(windturbineId))
+					{
+						shutdwonEvent=oldShutdownEvent.get(windturbineId);
+
+						if(shutdwonEvent==null)
+						{
+							shutdwonEvent=new ProEconShutdownEvent();
+							initalShutdownEvent(windturbineId, item, currentStatus, currentTime, shutdwonEvent);
+							oldShutdownEvent.put(windturbineId,shutdwonEvent);
+						}else
+						{
+							shutdwonEvent = finishShutdownEvent(shutdwonEventls,windturbineId, shutdwonEvent, currentStatus, currentTime);
+							oldShutdownEvent.put(windturbineId,null);
+						}
+
+
+					}
+					if(oldInterrup.containsKey(windturbineId))
+					{
+						interrup=oldInterrup.get(windturbineId);
+						if(interrup==null)
+						{
+							interrup=new ProEconInterruption();
+							initalInterruption(windturbineId, item, currentTime, interrup);
+							oldInterrup.put(windturbineId,interrup);
+						}else
+						{
+							interrup = finishInterruption(interrupls,windturbineId, interrup, currentStatus, currentTime);
+							oldInterrup.put(windturbineId,null);
+						}
+
+
+					}
+
+					if(oldShutdownEvent2.containsKey(windturbineId))
+					{
+						shutdwonEvent2=oldShutdownEvent2.get(windturbineId);
+						if(shutdwonEvent2==null)
+						{
+							shutdwonEvent2=new ProEconShutdownEvent2();
+							initalShutdownEvent2(windturbineId, item, currentStatus, currentTime, shutdwonEvent2);
+							oldShutdownEvent2.put(windturbineId,shutdwonEvent2);
+						}else
+						{
+							shutdwonEvent2 = finishShutdownEvent2(shutdwonEvent2ls,windturbineId, shutdwonEvent2, currentStatus, currentTime);
+							oldShutdownEvent2.put(windturbineId,null);
+						}
+
+					}
+
+					lastStatus=currentStatus;
+				}
+
+
+
+			}
+			//循环结束落盘,并清空
+			if(oldStatusMap.containsKey(windturbineId))
+			{
+				//获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
+				item=oldStatusMap.get(windturbineId);
+				if(item!=null)
+				{
+					ProEconWindturbineStatus finalItem = item;
+					QueryWrapper<ProEconWindturbineStatus> queryWrapper9 = new QueryWrapper<>();
+					queryWrapper9.eq("stop_Time",finalItem.getStopTime()).eq("windturbine_id",finalItem.getWindturbineId());
+					List<ProEconWindturbineStatus> ls= proEconWindturbineStatusService.list(queryWrapper9);
+//                            .stream().filter(i->i.getWindturbineId().equals(finalItem.getWindturbineId())
+//                                    && i.getStopTime().compareTo(finalItem.getStopTime())==0).collect(Collectors.toList());
+
+					if(ls.isEmpty())
+					{
+						//proEconWindturbineStatusService.save(item);
+
+						windturbineStatusls.add(item);
+
+						oldStatusMap.put(windturbineId,null);
+					}
+				}
+
+
+			}
+
+
+			if(oldShutdownEvent.containsKey(windturbineId))
+			{
+
+				shutdwonEvent=oldShutdownEvent.get(windturbineId);
+
+				if(shutdwonEvent!=null)
+				{
+					ProEconShutdownEvent finalShutdwonEvent = shutdwonEvent;
+					QueryWrapper<ProEconShutdownEvent> queryWrapper5 = new QueryWrapper<>();
+					queryWrapper5.eq("stop_Time",finalShutdwonEvent.getStopTime()).eq("windturbine_id",finalShutdwonEvent.getWindturbineId());
+					List<ProEconShutdownEvent> ls= proEconShutdownEventService.list(queryWrapper5);
+//                            .stream().filter(i->i.getWindturbineId().equals(finalShutdwonEvent.getWindturbineId())
+//                                    && i.getStopTime().compareTo(finalShutdwonEvent.getStopTime())==0)
+//                            .collect(Collectors.toList());
+
+					if(ls.isEmpty())
+					{
+						//proEconShutdownEventService.save(shutdwonEvent);
+						shutdwonEventls.add(shutdwonEvent);
+						oldShutdownEvent.put(windturbineId,null);
+					}
+				}
+
+			}
+			if(oldInterrup.containsKey(windturbineId))
+			{
+
+				interrup=oldInterrup.get(windturbineId);
+
+				if(interrup!=null)
+				{
+					ProEconInterruption finalInterrup = interrup;
+					QueryWrapper<ProEconInterruption> queryWrapper5 = new QueryWrapper<>();
+					queryWrapper5.eq("stop_Time",finalInterrup.getStopTime()).eq("windturbine_id",finalInterrup.getWindturbineId());
+					List<ProEconInterruption> ls= proEconInterruptionService.list(queryWrapper5);
+//                            .stream().filter(i->i.getWindturbineId().equals(finalInterrup.getWindturbineId())
+//                                    && i.getStopTime().compareTo(finalInterrup.getStopTime())==0).collect(Collectors.toList());
+
+					if(ls.isEmpty())
+					{
+						//proEconInterruptionService.save(interrup);
+						interrupls.add(interrup);
+						oldInterrup.put(windturbineId,null);
+					}
+				}
+
+
+			}
+
+			if(oldShutdownEvent2.containsKey(windturbineId))
+			{
+				shutdwonEvent2=oldShutdownEvent2.get(windturbineId);
+
+				if(shutdwonEvent2!=null)
+				{
+					ProEconShutdownEvent2 finalShutdwonEvent1 = shutdwonEvent2;
+					QueryWrapper<ProEconShutdownEvent2> queryWrapper5 = new QueryWrapper<>();
+					queryWrapper5.eq("stop_Time",finalShutdwonEvent1.getStopTime()).eq("windturbine_id",finalShutdwonEvent1.getWindturbineId());
+					List<ProEconShutdownEvent2> ls= proEconShutdownEvent2Service.list(queryWrapper5);
+//                            .stream().filter(i->i.getWindturbineId().equals(finalShutdwonEvent1.getWindturbineId())
+//                                    && i.getStopTime().compareTo(finalShutdwonEvent1.getStopTime())==0).collect(Collectors.toList());
+
+					if(ls.isEmpty())
+					{
+						//proEconShutdownEvent2Service.save(shutdwonEvent2);
+						shutdwonEvent2ls.add(shutdwonEvent2);
+						oldShutdownEvent2.put(windturbineId,null);
+					}
+				}
+
+			}
+
+			if(!windturbineStatusls.isEmpty())
+			{
+				proEconWindturbineStatusService.saveOrUpdateBatch(windturbineStatusls);
+			}
+			if(!shutdwonEventls.isEmpty())
+			{
+				proEconShutdownEventService.saveOrUpdateBatch(shutdwonEventls);
+			}
+			if(!shutdwonEvent2ls.isEmpty())
+			{
+				proEconShutdownEvent2Service.saveOrUpdateBatch(shutdwonEvent2ls);
+			}
+			if(!interrupls.isEmpty())
+			{
+				proEconInterruptionService.saveOrUpdateBatch(interrupls);
+			}
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		threadPoolTaskData = null;
+
+		return result;
+
+	}
+
+
+
+	private ProEconShutdownEvent finishShutdownEvent(List<ProEconShutdownEvent> shutdwonEventls,String windturbineId, ProEconShutdownEvent shutdwonEvent, Integer currentStatus, Date currentTime) throws Exception {
+//        if(currentStatus != 4 && currentStatus != 6)
+//        {
+		shutdwonEvent.setStartTime(currentTime);
+
+		double timehour=DateUtils.hoursDiff2(shutdwonEvent.getStartTime(), shutdwonEvent.getStopTime());
+		shutdwonEvent.setStopHours(timehour);
+		double losspower=calLossPower(windturbineId, shutdwonEvent.getStartTime(), shutdwonEvent.getStopTime());
+		shutdwonEvent.setLossPower(losspower);
+
+		shutdwonEventls.add(shutdwonEvent);
+//		proEconShutdownEventService.saveOrUpdate(shutdwonEvent);
+
+		oldShutdownEvent.put(windturbineId,null);
+		shutdwonEvent =null;
+//        }
+		return shutdwonEvent;
+	}
+
+	private ProEconInterruption finishInterruption(List<ProEconInterruption> interrupls,String windturbineId, ProEconInterruption interrup, Integer currentStatus, Date currentTime) {
+//        if(currentStatus != 12)
+//        {
+		interrup.setStartTime(currentTime);
+		double timehour=DateUtils.hoursDiff2(interrup.getStartTime(), interrup.getStopTime());
+		interrup.setStopHours(timehour);
+
+		interrupls.add(interrup);
+		//proEconInterruptionService.saveOrUpdate(interrup);
+		oldInterrup.put(windturbineId,null);
+		interrup =null;
+//        }
+		return interrup;
+	}
+
+	private ProEconShutdownEvent2 finishShutdownEvent2(List<ProEconShutdownEvent2> shutdwonEvent2ls,String windturbineId, ProEconShutdownEvent2 shutdwonEvent2, Integer currentStatus, Date currentTime) throws Exception {
+//        if(currentStatus != 4 && currentStatus != 6)
+//        {
+		shutdwonEvent2.setStartTime(currentTime);
+
+		double timehour=DateUtils.hoursDiff2(shutdwonEvent2.getStartTime(), shutdwonEvent2.getStopTime());
+		shutdwonEvent2.setStopHours(timehour);
+		double losspower=calLossPower(windturbineId, shutdwonEvent2.getStartTime(), shutdwonEvent2.getStopTime());
+		shutdwonEvent2.setLossPower(losspower);
+
+		if(timehour<=24)
+		{
+			//proEconShutdownEvent2Service.saveOrUpdate(shutdwonEvent2);
+			shutdwonEvent2ls.add(shutdwonEvent2);
+		}else
+		{
+			int days=DateUtils.daysDiff1(shutdwonEvent2.getStartTime(), shutdwonEvent2.getStopTime());
+			Calendar c=Calendar.getInstance();
+			Date startTime=shutdwonEvent2.getStartTime();
+			c.setTime(shutdwonEvent2.getStopTime());
+			c.set(Calendar.HOUR_OF_DAY,23);
+			c.set(Calendar.MINUTE,59);
+			c.set(Calendar.SECOND,59);
+			for(int i=0;i<days;i++)
+			{
+				if(i==0)
+				{
+					shutdwonEvent2.setStartTime(c.getTime());
+					losspower=calLossPower(windturbineId, shutdwonEvent2.getStartTime(), shutdwonEvent2.getStopTime());
+
+				}
+				else {
+					shutdwonEvent2.setStopTime(DateUtils.truncate(c.getTime()));
+					if(i==days-1)
+					{
+						shutdwonEvent2.setStartTime(startTime);
+
+					}else
+					{
+						shutdwonEvent2.setStartTime(c.getTime());
+
+					}
+					losspower=calLossPower(windturbineId, shutdwonEvent2.getStartTime(), shutdwonEvent2.getStopTime());
+				}
+				shutdwonEvent2.setLossPower(losspower);
+//				proEconShutdownEvent2Service.saveOrUpdate(shutdwonEvent2);
+				shutdwonEvent2ls.add(shutdwonEvent2);
+				c.add(Calendar.DAY_OF_MONTH,1);
+			}
+		}
+
+
+		shutdwonEvent2 =null;
+		oldShutdownEvent2.put(windturbineId,null);
+//        }
+		return shutdwonEvent2;
+	}
+
+	private void finishWindturbineStatus(List<ProEconWindturbineStatus> windturbineStatusls,String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date currentTime) throws Exception {
+		if(!Objects.equals(item.getSatusCode(), currentStatus))
+		{
+			item.setStartTime(currentTime);
+			double timehour=DateUtils.hoursDiff2(item.getStartTime(), item.getStopTime());
+			item.setStopHours(timehour);
+			double losspower=calLossPower(windturbineId, item.getStartTime(), item.getStopTime());
+			item.setLossPower(losspower);
+			windturbineStatusls.add(item);
+			//proEconWindturbineStatusService.saveOrUpdate(item);
+
+		}
+	}
+
+	private static void initalInterruption(String windturbineId, ProEconWindturbineStatus item, Date stopTime, ProEconInterruption interrup) {
+		interrup.setProjectId(CacheContext.wtmap.get(windturbineId).getProjectId());
+		interrup.setStopTime(stopTime);
+		interrup.setWindpowerstationId(CacheContext.wtmap.get(windturbineId).getWindpowerstationId());
+		interrup.setWindturbineId(windturbineId);
+	}
+
+	private static void initalShutdownEvent2(String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date stopTime, ProEconShutdownEvent2 shutdwonEvent2) {
+		shutdwonEvent2.setId(StringUtils.getUUID());
+		shutdwonEvent2.setProjectId(CacheContext.wtmap.get(windturbineId).getProjectId());
+		shutdwonEvent2.setStatusCode(currentStatus);
+		shutdwonEvent2.setStopTime(stopTime);
+		shutdwonEvent2.setWinpowerstationId(CacheContext.wtmap.get(windturbineId).getWindpowerstationId());
+		shutdwonEvent2.setWindturbineId(windturbineId);
+		if (currentStatus == 4)
+		{
+
+			shutdwonEvent2.setStopTypeId("gzbmq");
+			//读取报警记录表前后五分钟数据,选取第一个报警报警类型
+
+			// String stopTypeId =newMethod( windturbineId, begin, end);
+			String stopTypeId=null;
+			if (StringUtils.notEmp(stopTypeId))
+			{
+				shutdwonEvent2.setStopTypeId(stopTypeId);
+
+			}
+		}
+		else
+		{
+			shutdwonEvent2.setStopTypeId("wh");
+
+		}
+	}
+
+	private static void initalShutdownEvent(String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date stopTime, ProEconShutdownEvent shutdwonEvent) {
+
+		shutdwonEvent.setId(StringUtils.getUUID());
+		shutdwonEvent.setProjectId(CacheContext.wtmap.get(windturbineId).getProjectId());
+		shutdwonEvent.setStatusCode(currentStatus);
+		shutdwonEvent.setStopTime(stopTime);
+		shutdwonEvent.setWindpowerstationId(CacheContext.wtmap.get(windturbineId).getWindpowerstationId());
+		shutdwonEvent.setWindturbineId(windturbineId);
+		if (currentStatus == 4)
+		{
+
+			shutdwonEvent.setStoptypeId("gzbmq");
+
+			//读取报警记录表前后五分钟数据,选取第一个报警报警类型
+
+			// String stopTypeId =newMethod( windturbineId, begin, end);
+			String stopTypeId=null;
+			if (StringUtils.notEmp(stopTypeId))
+			{
+				shutdwonEvent.setStoptypeId(stopTypeId);
+
+			}
+		}
+		else
+		{
+			shutdwonEvent.setStoptypeId("wh");
+
+		}
+	}
+
+	private void initalWindturbineStatus(String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date stopTime,PointData stpo) {
+		item.setProjectId(CacheContext.wtmap.get(windturbineId).getProjectId());
+		item.setSatusCode(currentStatus);
+		item.setStatusDesc(statusDescriptionMap.get((int)stpo.getPointValueInDouble()));
+		item.setStopTime(stopTime);
+		item.setWindpowerstationId(CacheContext.wtmap.get(windturbineId).getWindpowerstationId());
+		item.setWindturbineId(windturbineId);
+	}
+
+
+	private  String newMethod( String windturbineId, Date begin, Date end)
+	{
+		String result = "";
+
+		return result;
+	}
+
+
+	private Double calLossPower(String windturbineId, Date startDate, Date endDate) throws Exception {
+		double result = 0.0;
+
+		Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+		Map<String, ProBasicEquipmentPoint> wtpointmap=wtpAimap.get(windturbineId);
+
+		Calendar c1=Calendar.getInstance();
+		c1.setTime(startDate);
+		Calendar c2=Calendar.getInstance();
+		c2.setTime(endDate);
+		//判定限电是否跨年
+		if(endDate.after(startDate) && c1.get(Calendar.YEAR)==c2.get(Calendar.YEAR))
+		{
+			//年故障损失电量
+			if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
+			{
+				double beginvalue;
+				double endvalue;
+
+				List<String> pointid=new ArrayList<>();
+				pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
+				List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
+				List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
+
+
+				if(xdbegin.size()==1 && xdend.size()==1)
+				{
+					beginvalue=xdbegin.get(0).getPointValueInDouble();
+					endvalue=xdend.get(0).getPointValueInDouble();
+
+					if (endvalue > beginvalue) {
+						result =result+(endvalue - beginvalue);
+					}
+				}
+			}
+
+
+		}else
+		{
+			Calendar c=Calendar.getInstance();
+			c.setTime(DateUtils.truncate(startDate));
+			c.add(Calendar.DAY_OF_MONTH,1);
+			//获得1月1日零点值
+			Date endtime=c.getTime();
+			//年故障损失电量
+			if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
+			{
+				double beginvalue;
+				double endvalue;
+
+
+
+				List<String> pointid=new ArrayList<>();
+				pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
+				List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
+				List<PointData> xdend=edosUtil.getHistMatrix(pointid,endtime.getTime()/1000);
+
+
+				if(xdbegin.size()==1 && xdend.size()==1)
+				{
+					beginvalue=xdbegin.get(0).getPointValueInDouble();
+					endvalue=xdend.get(0).getPointValueInDouble();
+
+					if (endvalue > beginvalue) {
+						result =result+(endvalue - beginvalue);
+					}
+				}
+			}
+
+			//日故障损失电量
+			if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
+			{
+
+				double endvalue;
+
+				List<String> pointid=new ArrayList<>();
+				pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
+				List<PointData> xdend=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
+
+				if(xdend.size()==1)
+				{
+
+					endvalue=xdend.get(0).getPointValueInDouble();
+
+					if (endvalue > 0) {
+						result =result+endvalue;
+					}
+				}
+			}
+
+		}
+
+		return result;
+
+	}
+}

+ 133 - 0
realtime/generationXK-service/src/main/resources/application-jn.yml

@@ -0,0 +1,133 @@
+
+server:
+  port: 7011
+  servlet:
+    context-path: /
+
+
+spring:
+  main:
+    allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
+  #redis集群
+  redis:
+    #host: 127.0.0.1
+    host: 10.81.3.155
+    port: 6379
+    timeout: 100000
+    #    集群环境打开下面注释,单机不需要打开
+    #    cluster:
+    #      #集群信息
+    #      nodes: 10.83.68.151:6379,10.83.68.152:6379,10.83.68.153:6379,10.83.68.154:6379,10.83.68.155:6379,10.83.68.156:6379,10.83.68.157:6379,10.83.68.158:6379,10.83.68.159:6379
+    #      #默认值是5 一般当此值设置过大时,容易报:Too many Cluster redirections
+    #      maxRedirects: 3
+    password:
+    application:
+      name: test
+    jedis:
+      pool:
+        max-active: 8
+        min-idle: 0
+        max-idle: 8
+        max-wait: -1
+    database: 9
+  autoconfigure:
+    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: org.postgresql.Driver
+    url: jdbc:postgresql://10.81.3.151:5432/IMS_NEM_JN?rewriteBatchedStatements=true
+    username: postgres
+    password: postgres
+    #    url: jdbc:postgresql://124.70.75.91:5432/jn_test?rewriteBatchedStatements=true
+    #    username: postgres
+    #    password: gd123
+    oracle-schema=:
+    #    type: com.alibaba.druid.pool.DruidDataSource
+    #    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC
+    #    username: root
+    #    password: root
+    #    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      max-active: 1000
+      initial-size: 1
+      min-idle: 3
+      max-wait: 60000
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+  servlet:
+    multipart:
+      # 开启 multipart 上传功能
+      enabled: true
+      # 文件写入磁盘的阈值
+      file-size-threshold: 2KB
+      # 最大文件大小
+      max-file-size: 200MB
+      # 最大请求大小
+      max-request-size: 215MB
+
+mybatis-plus:
+  configuration:
+    map-underscore-to-camel-case: true
+    auto-mapping-behavior: full
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  global-config:
+    # 逻辑删除配置
+    db-config:
+      id-type: auto
+      # 删除前
+      logic-not-delete-value: 1
+      # 删除后
+      logic-delete-value: 0
+logging:
+  level:
+    root: info
+    com.example: debug
+#db url
+db:
+  #url: http://127.0.0.1:8011/ts
+  url: http://10.81.3.152:8098/ts
+  #url: http://124.70.75.91:8011/ts
+#参与计算的场站
+#runWindpowerstation: SXJ_KGDL_GJY_FDC_STA
+runWindpowerstation: SXJ_KGDL_BHB3_FDC_STA,SXJ_KGDL_BHB_FDC_STA,SXJ_KGDL_GJY_FDC_STA,SXJ_KGDL_HSM_FDC_STA,SXJ_KGDL_NJL_FDC_STA,SXJ_KGDL_PDL_FDC_STA,SXJ_KGDL_PTZ_FDC_STA,SXJ_KGDL_SY_GDC_STA,SXJ_KGDL_XWT_FDC_STA,SXJ_KGDL_YF_FDC_STA,SXJ_KGDL_YLZ_FDC_STA,SXJ_KGDL_YTY_FDC_STA,SXJ_KGDL_ZK_FDC_STA
+#计算状态用ai或者di
+clauStatus:
+  ai: GJY03_GC,YLZ01_GC,PTZ02_GC   #配置期次
+  di: GJY01_GC,GJY02_GC,DJY01_GC,DJY02_GC,YF01_GC,YF02_GC,HSM01_GC,PTZ01_GC,ZK01_GC,NJL01_GC,YTY01_GC,PDL01_GC
+#判断数据终端
+second: 1800
+#判断降出力
+AI110: 17.4    #叶轮转速给定
+AI178: 17.4    #转矩给定
+#AI443:容量
+
+#功率曲线拟合
+curvefitting:
+  #维度
+  dimension: 20
+  #尺度
+  scale: 0.01
+initialcode: INITIAL
+##调用区间间隔时长,需要与XXLJOB调度时长结合,保证查询区间时长大于调度时长,单位分钟
+frequency:
+  #停机
+  shutdown: 6
+  #限电
+  powerrationing: 6
+  #切入切出
+  cutinandout: 6
+
+
+
+
+
+
+
+
+
+
+

+ 1 - 1
realtime/generationXK-service/src/main/resources/application.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: sl
+    active: jn
 #    active: yun
 
 #    active: td

+ 3 - 3
realtime/generationXK-service/src/main/resources/xxl-job-executor.properties

@@ -1,12 +1,12 @@
 ### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
-xxl.job.admin.addresses=http://localhost:8175/xxl-job-admin
-
+#xxl.job.admin.addresses=http://localhost:8175/xxl-job-admin
+xxl.job.admin.addresses=http://10.81.3.152:8175/xxl-job-admin
 ### xxl-job, access token
 xxl.job.accessToken=
 
 ### xxl-job executor appname
 ### ³¡Õ¾¼ÆËã
-xxl.job.executor.appname=generationWP-job
+xxl.job.executor.appname=generationTarget-job
 ### ÇøÓò¹«Ë¾¼ÆËã
 #xxl.job.executor.appname=generationRG-job
 ### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null

+ 21 - 0
realtime/generationXK-service/src/main/resources/xxl-job-executorJN.properties

@@ -0,0 +1,21 @@
+### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
+xxl.job.admin.addresses=http://10.81.3.155:8175/xxl-job-admin
+
+### xxl-job, access token
+xxl.job.accessToken=
+
+### xxl-job executor appname
+### ³¡Õ¾¼ÆËã
+xxl.job.executor.appname=generationJN-job
+
+xxl.job.executor.address=
+### xxl-job executor server-info
+xxl.job.executor.ip=
+#³¡Õ¾¶Ë¿Ú
+xxl.job.executor.port=9114
+
+### xxl-job executor log-path
+xxl.job.executor.logpath=/usr/local/gyee/generationJN/logs
+
+xxl.job.executor.logretentiondays=30
+

+ 197 - 0
realtime/generationXK-service/src/test/java/com/gyee/generation/HealthTest.java

@@ -0,0 +1,197 @@
+package com.gyee.generation;
+
+import org.springframework.boot.SpringApplication;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class HealthTest {
+
+
+    public static void main(String[] args) throws Exception {
+        SpringApplication.run(GenerationMain.class, args);
+
+        Date begin=null;
+        Date end=null;
+//        CacheService cacheService= SpringUtils.getBean("cacheService");
+//        cacheService.initRedisCache();
+//
+//
+        Calendar c = Calendar.getInstance();
+        //
+//        System.out.println("故障转换率记录调度程序执行开始!。。。。。。");
+//        TimelinessRateService timelinessRateService = SpringUtils.getBean("timelinessRateService");
+//        timelinessRateService.failRate(c.getTime());
+//        System.out.println("故障转换率记录调度程序执行结束!。。。。。。");
+//
+//        begin=new Date();
+//        System.out.println("切15分钟数据统计记录调度程序执行开始!。。。。。。");
+//        EquipmentInfo15minuteService equipmentInfo15minuteService = SpringUtils.getBean("equipmentInfo15minuteService");
+//        equipmentInfo15minuteService.calEquipmentInfo15minute(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("切15分钟数据统计记录记录调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("切入切出状态切换记录调度程序执行开始!。。。。。。");
+//        InputOrOutPutService inputOrOutPutService= SpringUtils.getBean("inputOrOutPutService");
+//
+//        inputOrOutPutService.inputOrOutputSpeed(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("切入切出状态切换记录调度程序执行结束!。。。。。。");
+//
+//        begin=new Date();
+//        System.out.println("切入切出统计调度程序执行开始!。。。。。。");
+//        InputOrOutPutService inputOrOutPutService= SpringUtils.getBean("inputOrOutPutService");
+//
+//        inputOrOutPutService.inputOrOutput(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("切入切出统计调度程序执行结束!。。。。。。");
+//
+//
+//
+//        begin=new Date();
+//        System.out.println("停机记录调度程序执行开始!。。。。。。");
+//        ShutdownnewService shutdownnewService= SpringUtils.getBean("shutdownnewService");
+//
+//        shutdownnewService.execShutdown(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("停机记录调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("限电停机记录调度程序执行开始!。。。。。。");
+//        LimitEventnewService limitEventnewService= SpringUtils.getBean("limitEventnewService");
+//
+//        limitEventnewService.execBrownouts(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("限电停机记录调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("曲线拟合调度程序执行开始!。。。。。。");
+//        PowerCurveFittingByTimeService powerCurveFittingByTimeService= SpringUtils.getBean("powerCurveFittingByTimeService");
+//
+//        XxlJobHelper.log("日序执行开始!........");
+//        powerCurveFittingByTimeService.cureFittingDay(c.getTime());
+//        XxlJobHelper.log("日处理完成!........");
+//
+//        XxlJobHelper.log("月序执行开始!........");
+//        powerCurveFittingByTimeService.cureFittingMonth(c.getTime(),"0");
+//        XxlJobHelper.log("月处理完成!........");
+//
+//        XxlJobHelper.log("年序执行开始!........");
+//        powerCurveFittingByTimeService.cureFittingYear(c.getTime());
+//        XxlJobHelper.log("年处理完成!........");
+//
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("曲线拟合调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("场站指标记录调度程序执行开始!。。。。。。");
+//        WindPowerInfo1Service windPowerInfo1Service= SpringUtils.getBean("windPowerInfo1Service");
+//        WindPowerInfo2Service windPowerInfo2Service= SpringUtils.getBean("windPowerInfo2Service");
+//        WindPowerInfo3Service windPowerInfo3Service= SpringUtils.getBean("windPowerInfo3Service");
+//        WindPowerInfo4Service windPowerInfo4Service= SpringUtils.getBean("windPowerInfo4Service");
+//        WindPowerInfo5Service windPowerInfo5Service= SpringUtils.getBean("windPowerInfo5Service");
+//        WindPowerInfo6Service windPowerInfo6Service= SpringUtils.getBean("windPowerInfo6Service");
+//
+//        windPowerInfo1Service.calLineInfoDay(c.getTime());
+//        windPowerInfo1Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo1Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo1Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo1Service.calRegionInfoDay(c.getTime());
+//
+//        windPowerInfo2Service.calLineInfoDay(c.getTime());
+//        windPowerInfo2Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo2Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo2Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo2Service.calRegionInfoDay(c.getTime());
+//
+//        windPowerInfo3Service.calLineInfoDay(c.getTime());
+//        windPowerInfo3Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo3Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo3Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo3Service.calRegionInfoDay(c.getTime());
+//
+//        windPowerInfo4Service.calLineInfoDay(c.getTime());
+//        windPowerInfo4Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo4Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo4Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo4Service.calRegionInfoDay(c.getTime());
+//
+//        windPowerInfo5Service.calLineInfoDay(c.getTime());
+//        windPowerInfo5Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo5Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo5Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo5Service.calRegionInfoDay(c.getTime());
+//
+//        windPowerInfo6Service.calLineInfoDay(c.getTime());
+//        windPowerInfo6Service.calProjectInfoDay(c.getTime());
+//        windPowerInfo6Service.calWindpowerInfoDay(c.getTime());
+//        windPowerInfo6Service.calCompanyInfoDay(c.getTime());
+//        windPowerInfo6Service.calRegionInfoDay(c.getTime());
+//
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("场站指标记录调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("设备指标记录调度程序执行开始!。。。。。。");
+//       EquipmentInfo1Service equipmentInfo1Service= SpringUtils.getBean("equipmentInfo1Service");
+//        EquipmentInfo2Service equipmentInfo2Service= SpringUtils.getBean("equipmentInfo2Service");
+//        EquipmentInfo3Service equipmentInfo3Service= SpringUtils.getBean("equipmentInfo3Service");
+//        EquipmentInfo4Service equipmentInfo4Service= SpringUtils.getBean("equipmentInfo4Service");
+//        EquipmentInfo5Service equipmentInfo5Service= SpringUtils.getBean("equipmentInfo5Service");
+//        EquipmentInfoDayTopService equipmentInfoDayTopService= SpringUtils.getBean("equipmentInfoDayTopService");
+//        WtAlysisDayService wtAlysisDayService= SpringUtils.getBean("wtAlysisDayService");
+//
+//        equipmentInfo1Service.calEquipmentInfoDay(c.getTime());
+//
+//        equipmentInfo2Service.calEquipmentInfoDay(c.getTime());
+//
+//        equipmentInfo3Service.calEquipmentInfoDay(c.getTime());
+//
+//        equipmentInfo4Service.calEquipmentInfoDay(c.getTime());
+//
+//        equipmentInfo5Service.calEquipmentInfoDay(c.getTime());
+//
+//        equipmentInfoDayTopService.calEquipmentInfoDayTop(new Date());
+//        equipmentInfoDayTopService.calEquipmentInfoMonthTop(new Date());
+//        equipmentInfoDayTopService.calEquipmentInfoYearTop(new Date());
+//
+//        wtAlysisDayService.calEquipmentInfoDay(new Date());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("设备指标记录调度程序执行结束!。。。。。。");
+//
+//
+//        begin=new Date();
+//        System.out.println("功率一致性系数和拟合优度调度程序执行开始!。。。。。。");
+//        WindturbineGoodnessService windturbineGoodnessService= SpringUtils.getBean("windturbineGoodnessService");
+//
+//        windturbineGoodnessService.calWindturbineGoodness(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("功率一致性系数和拟合优度调度程序执行结束!。。。。。。");
+//
+//        c.add(Calendar.DAY_OF_MONTH,-1);
+//        begin=new Date();
+//        System.out.println("设备数据和场站数据风资源调度程序执行开始!。。。。。。");
+//        WpwindDayInfoService wpwindDayInfoService= SpringUtils.getBean("wpwindDayInfoService");
+//        WtwindDayInfoService wtwindDayInfoService= SpringUtils.getBean("wtwindDayInfoService");
+//        wpwindDayInfoService.calWpwindDayInfo(c.getTime());
+//        wtwindDayInfoService.calWtwindDayInfo(c.getTime());
+//        end=new Date();
+//        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+//        System.out.println("设备数据和场站数据风资源调度程序执行结束!。。。。。。");
+    }
+}