Browse Source

信控集控服务重新开发停机和限电的修改

shilin 2 years ago
parent
commit
92492e79be
21 changed files with 2182 additions and 242 deletions
  1. 23 14
      realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java
  2. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/config/GeneratorCodeConfig.java
  3. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/mapper/auto/ProBasicPowerstationMapper.java
  4. 3 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProBasicModelPowerRd.java
  5. 1 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconBrownoutsEvent.java
  6. 1 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconBrownoutsEvent2.java
  7. 2 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconInOrOutSpeedTotal.java
  8. 2 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconInOrOutSpeedTotal2.java
  9. 0 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconMainBrownouts.java
  10. 0 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconMainBrownouts2.java
  11. 96 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/InputOrOutPutService.java
  12. 1052 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/LimitEventnewService.java
  13. 82 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingModelService.java
  14. 249 201
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownService.java
  15. 612 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java
  16. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProBasicPowerstationService.java
  17. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProBasicPowerstationServiceImpl.java
  18. 2 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/initialpoint/InitialPointGoldenXkByEqService.java
  19. 3 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/util/DateUtils.java
  20. 1 1
      realtime/generationXK-service/src/main/resources/application-xk.yml
  21. 49 0
      realtime/generationXK-service/src/test/java/com/gyee/generation/PgCalTest.java

+ 23 - 14
realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java

@@ -1,13 +1,11 @@
 package com.gyee.generation;
 
-import com.gyee.generation.service.initialpoint.InitialPointGoldenXkByEqService;
+import com.gyee.generation.service.InputOrOutPutService;
 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.io.IOException;
-
 /**
  * @ClassName : GenerationMain
  * @Author : xieshengjie
@@ -17,7 +15,7 @@ import java.io.IOException;
 @SpringBootApplication
 @MapperScan("com.gyee.generation.mapper")
 public class GenerationMain {
-    public static void main(String[] args) throws IOException {
+    public static void main(String[] args) throws Exception {
         SpringApplication.run(GenerationMain.class,args);
 
 
@@ -29,16 +27,27 @@ public class GenerationMain {
 //        System.out.println("开始导出风场测点。。。。。。");
 //        InitialPointGoldenXkService.initalFc();
 //        System.out.println("结束导出风场测点。。。。。。");
-
-        InitialPointGoldenXkByEqService initialPointGoldenXkByEqService= SpringUtils.getBean("initialPointGoldenXkByEqService");
-
-        System.out.println("开始导出风机测点。。。。。。");
-        initialPointGoldenXkByEqService.initalFj();
-        System.out.println("结束导出风机测点。。。。。。");
-
-        System.out.println("开始导出风场测点。。。。。。");
-        initialPointGoldenXkByEqService.initalFc();
-        System.out.println("结束导出风场测点。。。。。。");
+//
+//        InitialPointGoldenXkByEqService initialPointGoldenXkByEqService= SpringUtils.getBean("initialPointGoldenXkByEqService");
+//
+//        System.out.println("开始导出风机测点。。。。。。");
+//        initialPointGoldenXkByEqService.initalFj();
+//        System.out.println("结束导出风机测点。。。。。。");
+//
+//        System.out.println("开始导出风场测点。。。。。。");
+//        initialPointGoldenXkByEqService.initalFc();
+//        System.out.println("结束导出风场测点。。。。。。");
+//        PowerCurveFittingModelService powerCurveFittingModelService= SpringUtils.getBean("powerCurveFittingModelService");
+//
+//        powerCurveFittingModelService.cureFittingModel();
+//        CacheService cacheService= SpringUtils.getBean("cacheService");
+//        cacheService.initRedisCache();
+        InputOrOutPutService inputOrOutPutService= SpringUtils.getBean("inputOrOutPutService");
+//        inputOrOutPutService.inputOrOutput(new Date());
+        while(true)
+        {
+            inputOrOutPutService.inputOrOutputSpeed();
+        }
 
     }
 }

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

@@ -61,7 +61,7 @@ public class GeneratorCodeConfig {
         dsc.setDriverName("org.postgresql.Driver");
         dsc.setUsername("postgres");
         dsc.setPassword("postgres");
-        dsc.setUrl("jdbc:postgresql://192.168.11.248:5432/IMS_NEM");
+        dsc.setUrl("jdbc:postgresql://192.168.11.248:5432/IMS_NEM_SD");
 //        dsc.setUrl("jdbc:postgresql://120.46.148.180:5432/postgres");
 //        dsc.setUsername("gdprod");
 //        dsc.setPassword("gd123");

+ 1 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/mapper/auto/ProBasicPowerstationMapper.java

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * </p>
  *
  * @author shilin
- * @since 2022-10-31
+ * @since 2022-11-12
  */
 public interface ProBasicPowerstationMapper extends BaseMapper<ProBasicPowerstation> {
 

+ 3 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProBasicModelPowerRd.java

@@ -1,6 +1,7 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -18,7 +19,7 @@ import lombok.EqualsAndHashCode;
 public class ProBasicModelPowerRd extends Model {
 
     private static final long serialVersionUID = 1L;
-
+    @TableId(value = "ID",type = IdType.ASSIGN_ID)
     private String id;
 
     private String modelId;

+ 1 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconBrownoutsEvent.java

@@ -1,8 +1,6 @@
 package com.gyee.generation.model.auto;
 
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -27,7 +25,7 @@ public class ProEconBrownoutsEvent extends Model {
      * 编号
      */
 
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
+
     private String id;
 
     /**

+ 1 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconBrownoutsEvent2.java

@@ -1,7 +1,5 @@
 package com.gyee.generation.model.auto;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -25,7 +23,7 @@ public class ProEconBrownoutsEvent2 extends Model {
     /**
      * 编号
      */
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
+
     private String id;
 
     /**

+ 2 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconInOrOutSpeedTotal.java

@@ -26,8 +26,8 @@ public class ProEconInOrOutSpeedTotal extends Model {
     /**
      * 编号
      */
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
-    private Integer id;
+    @TableId(value = "id",type = IdType.ASSIGN_UUID)
+    private String id;
 
     /**
      * 风机编号

+ 2 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconInOrOutSpeedTotal2.java

@@ -26,8 +26,8 @@ public class ProEconInOrOutSpeedTotal2 extends Model {
     /**
      * 编号
      */
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
-    private Integer id;
+    @TableId(value = "id",type = IdType.ASSIGN_UUID)
+    private String id;
 
     /**
      * 风机编号

+ 0 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconMainBrownouts.java

@@ -1,7 +1,5 @@
 package com.gyee.generation.model.auto;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -26,7 +24,6 @@ public class ProEconMainBrownouts extends Model {
     /**
      * 编号
      */
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
     private String id;
 
     /**

+ 0 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconMainBrownouts2.java

@@ -1,7 +1,5 @@
 package com.gyee.generation.model.auto;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -25,7 +23,6 @@ public class ProEconMainBrownouts2 extends Model {
     /**
      * 编号
      */
-    @TableId(value = "ID",type = IdType.ASSIGN_ID)
     private String id;
 
     /**

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

@@ -1,6 +1,8 @@
 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.service.auto.IProEconInOrOutSpeedTotal2Service;
@@ -8,6 +10,7 @@ import com.gyee.generation.service.auto.IProEconInOrOutSpeedTotalService;
 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.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -19,7 +22,8 @@ import java.util.stream.Collectors;
 @Service
 public class InputOrOutPutService {
 
-
+    @Resource
+    private IEdosUtil edosUtil;
     @Resource
     private IProEconInOrOutSpeedTotal2Service proEconInOrOutSpeedTotal2Service;
     @Resource
@@ -27,6 +31,97 @@ public class InputOrOutPutService {
     @Resource
     private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
 
+
+    private Map<String,Double> lastStatusMap=new HashMap<>();
+
+    public void inputOrOutputSpeed() throws Exception {
+       
+        for(ProBasicEquipment wt:CacheContext.wtls)
+        {
+
+            Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getNemCode());
+
+            double lastStatus=-1;
+            if(lastStatusMap.containsKey(wt.getId()))
+            {
+                 lastStatus=lastStatusMap.get(wt.getId());
+            }else
+            {
+                lastStatus = getLastStatus(pointmap);
+            }
+
+
+            ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.MXZT);
+
+            PointData mxztData= edosUtil.getRealData(mxzt.getNemCode());
+
+            double status=mxztData.getPointValueInDouble();
+            if (!Objects.equals(lastStatus, status))
+            {
+
+                //    #region 切入切出风速
+                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(new Date());
+                    input.setInputOrOutput(1);
+
+                    ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
+                        double value =edosUtil.getRealData(ssfs.getNemCode()).getPointValueInDouble();
+                        input.setSpeed(value);
+
+                    proEconInputOrOutputSpeedService.save(input);
+
+
+
+                }
+                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(new Date());
+                    input.setInputOrOutput(0);
+
+                    ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
+                    double value =edosUtil.getRealData(ssfs.getNemCode()).getPointValueInDouble();
+                    input.setSpeed(value);
+                    proEconInputOrOutputSpeedService.save(input);
+                }
+
+                lastStatusMap.put(wt.getId(), getLastStatus(pointmap));
+
+            }
+            
+            
+        }
+
+       
+    }
+
+    private double getLastStatus(Map<String, ProBasicEquipmentPoint> pointmap) throws Exception {
+        double lastStatus;
+        ProBasicEquipmentPoint power= pointmap.get(ContantXk.CJ_SSGL);
+        double powerdata =edosUtil.getRealData(power.getNemCode()).getPointValueInDouble();
+        if (powerdata > 1)
+        {
+             lastStatus=powerdata == 9 ? 2 :  powerdata;
+
+        }
+        else
+        {
+             lastStatus=powerdata == 9 ? 0 :  powerdata;
+
+        }
+        return lastStatus;
+    }
+
     public void inputOrOutput(Date currentDate) {
         currentDate = DateUtils.truncDay(currentDate);
         Date end = currentDate;

File diff suppressed because it is too large
+ 1052 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/LimitEventnewService.java


+ 82 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingModelService.java

@@ -0,0 +1,82 @@
+package com.gyee.generation.service;
+
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.ProBasicModelPower;
+import com.gyee.generation.model.auto.ProBasicModelPowerRd;
+import com.gyee.generation.model.vo.PointVo;
+import com.gyee.generation.service.auto.IProBasicModelPowerRdService;
+import com.gyee.generation.util.StringUtils;
+import com.gyee.generation.util.realtimesource.math.LineUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class PowerCurveFittingModelService {
+
+//    private static final Logger logger = LoggerFactory.getLogger(PowerCurveFittingModelService.class);
+
+    @Value("${curvefitting.dimension}")
+    private Integer dimension;
+    @Value("${curvefitting.scale}")
+    private Double scale;
+
+
+    @Resource
+    private IProBasicModelPowerRdService proBasicModelPowerRdService;
+
+
+    public void cureFittingModel() {
+
+
+        Map<String, List<ProBasicModelPower>> modelpmap = new TreeMap<>();
+
+        for (ProBasicModelPower mp : CacheContext.mpls) {
+            if (modelpmap.containsKey(mp.getModelId())) {
+                List<ProBasicModelPower> ls = modelpmap.get(mp.getModelId());
+                ls.add(mp);
+
+            } else {
+                List<ProBasicModelPower> ls = new ArrayList<>();
+                ls.add(mp);
+                modelpmap.put(mp.getModelId(), ls);
+            }
+        }
+
+
+        for (String key : modelpmap.keySet()) {
+            List<ProBasicModelPower> ls = modelpmap.get(key);
+            if (!ls.isEmpty()) {
+                ls = ls.stream().sorted(Comparator.comparing(ProBasicModelPower::getSpeed)).collect(Collectors.toList());
+                //理论功率拟合
+                List<PointVo> llls = LineUtil.buildLine(ls.stream().mapToDouble(ProBasicModelPower::getSpeed).toArray(), ls.stream().mapToDouble(ProBasicModelPower::getTheoryPower).toArray(), ls.size(), dimension, scale);
+                //保证功率拟合
+                List<PointVo> bzls = LineUtil.buildLine(ls.stream().mapToDouble(ProBasicModelPower::getSpeed).toArray(), ls.stream().mapToDouble(ProBasicModelPower::getEnsurePower).toArray(), ls.size(), dimension, scale);
+
+
+                if (!llls.isEmpty() && !bzls.isEmpty() && llls.size() == bzls.size()) {
+                    for (int i = 0; i < llls.size(); i++) {
+                        ProBasicModelPowerRd rd = new ProBasicModelPowerRd();
+                        rd.setModelId(ls.get(0).getModelId());
+                        rd.setWindpowerstationId(ls.get(0).getWindpowerstationId());
+                        rd.setEnsurePower(StringUtils.round(bzls.get(i).getY(),2));
+                        rd.setTheoryPower(StringUtils.round(llls.get(i).getY(),2));
+                        rd.setSpeed(StringUtils.round(llls.get(i).getX(),2));
+                        proBasicModelPowerRdService.save(rd);
+                    }
+
+                }
+
+
+            }
+
+        }
+
+
+    }
+
+
+}

+ 249 - 201
realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownService.java

@@ -94,12 +94,6 @@ public class ShutdownService {
 
     public void init()
     {
-//        statusDescription.put(0, "待机");
-//        statusDescription.put(1, "并网");
-//        statusDescription.put(2, "停机");
-//        statusDescription.put(3, "通讯中断");
-//        statusDescription.put(4, "维护");
-//        statusDescription.put(5, "限电");
 
         statusDescription.put(0, "待机");
         statusDescription.put(1, "手动停机");
@@ -196,30 +190,6 @@ public class ShutdownService {
         }
 
 
-//        List<ProBasicModelPowerRd>  pbmprls=proBasicModelPowerRdService.list().stream()
-//
-//                .sorted(Comparator.comparing(ProBasicModelPowerRd::getSpeed)).collect(Collectors.toList());
-//
-//
-//        if(!pbmprls.isEmpty())
-//        {
-//            for(ProBasicModelPowerRd pwpcf:pbmprls)
-//            {
-//
-//                if(modelPowerMap.containsKey(pwpcf.getId()))
-//                {
-//                    Map<Double, ProBasicModelPowerRd> map =modelPowerMap.get(pwpcf.getId());
-//                    map.put(pwpcf.getSpeed(),pwpcf);
-//                    modelPowerMap.put(pwpcf.getId(),map);
-//                }else
-//                {
-//                    Map<Double, ProBasicModelPowerRd> map = new HashMap<Double, ProBasicModelPowerRd>();
-//                    map.put(pwpcf.getSpeed(),pwpcf);
-//                    modelPowerMap.put(pwpcf.getId(),map);
-//                }
-//
-//            }
-//        }
 
     }
 
@@ -251,7 +221,7 @@ public class ShutdownService {
 
             if (power > 1)
             {
-                status.put(key,value == 9 ? 1 : (int) value);
+                status.put(key,value == 9 ? 2 : (int) value);
 
             }
             else
@@ -263,8 +233,6 @@ public class ShutdownService {
             oldStatusMap.put(key, null);
             oldShutdownEvent.put(key, null);
             oldInterrup.put(key, null);
-
-           // 新增 shutdownevent2 实时
             oldShutdownEvent2.put(key, null);
 
         }
@@ -330,59 +298,131 @@ public class ShutdownService {
 
 
 
-            for (String s : oldStatusMap.keySet())
+            for (String windturbineId : oldStatusMap.keySet())
             {
-                ProEconWindturbineStatus item = oldStatusMap.get(s);
+                ProEconWindturbineStatus item = oldStatusMap.get(windturbineId);
 
                 if (item == null)
                 {
 
-                    //logger.debug("{0}重复加入 风机编号{1}", date,s);
+                    //logger.debug("{0}重复加入 风机编号{1}", date,windturbineId);
 
-                    ProEconShutdownEvent shutdwonEvent=new ProEconShutdownEvent();
-                    ProEconInterruption interrup=new ProEconInterruption();
+                    ProEconShutdownEvent shutdwonEvent=null;
+                    ProEconInterruption interrup=null;
 
                     //新增 shutdownevent2 实时
-                    ProEconShutdownEvent2 shutdwonEvent2=new ProEconShutdownEvent2();
+                    ProEconShutdownEvent2 shutdwonEvent2=null;
 
 
-                    item = buildWindturbineStatus(s, date,  shutdwonEvent,  interrup,  shutdwonEvent2);
 
+                    ProEconWindturbineStatus retValue = new ProEconWindturbineStatus();
 
+                    retValue.setProjectId(windTurbines.get(windturbineId).getProjectId());
+                    retValue.setSatusCode(status.get(windturbineId));
+                    retValue.setStatusDesc(statusDescription.get(status.get(windturbineId)));
+                    retValue.setStopTime(date);
+                    retValue.setWindpowerstationId(windTurbines.get(windturbineId).getWindpowerstationId());
+                    retValue.setWindturbineId(windturbineId);
 
-                    proEconWindturbineStatusService.save(item);
+                    Integer currentStatus = status.get(windturbineId);
+                    if (currentStatus == 4 || currentStatus == 6)
+                    {
+                        shutdwonEvent=new ProEconShutdownEvent();
+                        shutdwonEvent.setId(StringUtils.getUUID());
+                        shutdwonEvent.setProjectId(retValue.getProjectId());
+                        shutdwonEvent.setStatusCode(currentStatus);
+                        shutdwonEvent.setStopTime(date);
+                        shutdwonEvent.setWindpowerstationId(retValue.getWindpowerstationId());
+                        shutdwonEvent.setWindturbineId(windturbineId);
+
+
+                        shutdwonEvent2=new ProEconShutdownEvent2();
+                        shutdwonEvent2.setId(StringUtils.getUUID());
+                        shutdwonEvent2.setProjectId(retValue.getProjectId());
+                        shutdwonEvent2.setStatusCode(currentStatus);
+                        shutdwonEvent2.setStopTime(date);
+                        shutdwonEvent2.setWinpowerstationId(retValue.getWindpowerstationId());
+                        shutdwonEvent2.setWindturbineId(windturbineId);
+
+                        if (currentStatus == 4)
+                        {
 
-                    proEconShutdownEventService.save(shutdwonEvent);
+                            Date begin =DateUtils.addMinutes(date,-5);
+                            Date end = DateUtils.addMinutes(date,5);
+                            shutdwonEvent.setStoptypeId("gzbmq");
+                            shutdwonEvent2.setStopTypeId("gzbmq");
+                            //读取报警记录表前后五分钟数据,选取第一个报警报警类型
+                            String str =newMethod( windturbineId, begin, end);
+                            if (StringUtils.notEmp(windturbineId))
+                            {
 
-                    proEconInterruptionService.save(interrup);
+                                shutdwonEvent.setStoptypeId(windturbineId);
+                                shutdwonEvent2.setStopTypeId(windturbineId);
 
-                     //  新增 shutdownevent2 实时
-                    //20分钟以内的报警数据
-                    Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-15);
-                    Date dtend = shutdwonEvent2.getStopTime();
+                            }
+                        }
+                        else
+                        {
+                            shutdwonEvent.setStoptypeId("wh");
+                            shutdwonEvent2.setStopTypeId("wh");
 
-                    Optional<ProEconShutdownEvent2> olditemo= proEconShutdownEvent2Service.list().stream()
-                            .filter(i -> i.getWindturbineId().equals(s)
-                                    && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
-                                    && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
+                        }
+                        retValue.setShutdownEventId(shutdwonEvent.getId());
+                    }
+                    if (currentStatus == 12)
+                    {
+                        interrup=new ProEconInterruption();
+                        interrup.setProjectId(retValue.getProjectId());
+                        interrup.setStopTime(date);
+                        interrup.setWindpowerstationId(retValue.getWindpowerstationId());
+                        interrup.setWindturbineId(windturbineId);
+                    }
 
-                            ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
+                    proEconWindturbineStatusService.save(item);
 
-                    ProEconShutdownEvent2 lditem;
-                    if (!olditemo.isPresent())
+                    if (shutdwonEvent != null)
                     {
-                        proEconShutdownEvent2Service.save(shutdwonEvent2);
-
+                        proEconShutdownEventService.save(shutdwonEvent);
                     }
-                    else
+                    if (shutdwonEvent != null)
                     {
-                        lditem=olditemo.get();
-                        lditem.setStartTime(null);
-                        if (!oldShutdownEvent2.containsKey(lditem.getWindturbineId()))
-                            oldShutdownEvent2.put(lditem.getWindturbineId(), lditem);
+                        proEconInterruptionService.save(interrup);
+                    }
+
+
+
+
+                    if (shutdwonEvent2 != null)
+                    {
+//  新增 shutdownevent2 实时
+                        //20分钟以内的报警数据
+                        Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-15);
+                        Date dtend = shutdwonEvent2.getStopTime();
+
+                        Optional<ProEconShutdownEvent2> olditemo= proEconShutdownEvent2Service.list().stream()
+                                .filter(i -> i.getWindturbineId().equals(windturbineId)
+                                        && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
+                                        && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
+
+                                ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
+
+                        ProEconShutdownEvent2 lditem;
+                        if (!olditemo.isPresent())
+                        {
+                            proEconShutdownEvent2Service.save(shutdwonEvent2);
 
+                        }
+                        else
+                        {
+                            lditem=olditemo.get();
+                            lditem.setStartTime(null);
+                            if (!oldShutdownEvent2.containsKey(lditem.getWindturbineId()))
+                                oldShutdownEvent2.put(lditem.getWindturbineId(), lditem);
+
+                        }
                     }
 
+
                     continue;
                 }
 
@@ -391,47 +431,47 @@ public class ShutdownService {
                 c.setTime(date);
                 if (c.get(Calendar.HOUR_OF_DAY) == 0 &&c.get(Calendar.MINUTE) == 0)
                 {
-                    logger.debug("{0}--整点操作--{1}", s, date);
+                    logger.debug("{0}--整点操作--{1}", windturbineId, date);
 
                     updateAndAddStatus( item);
                 }
-                else if (!Objects.equals(item.getSatusCode(), status.get(s)))
+                else if (!Objects.equals(item.getSatusCode(), status.get(windturbineId)))
                 {
                     updateAndAddStatus(item);
 
                     //    #region 切入切出风速
-                    if (item.getSatusCode() == 0 && status.get(s) == 2)
+                    if (item.getSatusCode() == 0 && status.get(windturbineId) == 2)
                     {
                         ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
-                        input.setWindturbineId(s);
-                        input.setWindpowerstationId(windTurbines.get(s).getWindpowerstationId());
-                        input.setProjectId(windTurbines.get(s).getProjectId());
-                        input.setLineId(windTurbines.get(s).getLineId());
+                        input.setWindturbineId(windturbineId);
+                        input.setWindpowerstationId(windTurbines.get(windturbineId).getWindpowerstationId());
+                        input.setProjectId(windTurbines.get(windturbineId).getProjectId());
+                        input.setLineId(windTurbines.get(windturbineId).getLineId());
                         input.setRecordDate(date);
                         input.setInputOrOutput(1);
 
 
-                        if (speedpointMap.containsKey(s))
+                        if (speedpointMap.containsKey(windturbineId))
                         {
-                            double value =edosUtil.getRealData(speedpointMap.get(s).getNemCode()).getPointValueInDouble();
+                            double value =edosUtil.getRealData(speedpointMap.get(windturbineId).getNemCode()).getPointValueInDouble();
                             input.setSpeed(value);
                         }
 
                         proEconInputOrOutputSpeedService.save(input);
 
                     }
-                    else if (item.getSatusCode() == 1 && status.get(s)== 0)
+                    else if (item.getSatusCode() == 2 && status.get(windturbineId)== 0)
                     {
                         ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
-                        input.setWindturbineId(s);
-                        input.setWindpowerstationId(windTurbines.get(s).getWindpowerstationId());
-                        input.setProjectId(windTurbines.get(s).getProjectId());
-                        input.setLineId(windTurbines.get(s).getLineId());
+                        input.setWindturbineId(windturbineId);
+                        input.setWindpowerstationId(windTurbines.get(windturbineId).getWindpowerstationId());
+                        input.setProjectId(windTurbines.get(windturbineId).getProjectId());
+                        input.setLineId(windTurbines.get(windturbineId).getLineId());
                         input.setRecordDate(date);
                         input.setInputOrOutput(0);
-                        if (speedpointMap.containsKey(s))
+                        if (speedpointMap.containsKey(windturbineId))
                         {
-                            double value =edosUtil.getRealData(speedpointMap.get(s).getNemCode()).getPointValueInDouble();
+                            double value =edosUtil.getRealData(speedpointMap.get(windturbineId).getNemCode()).getPointValueInDouble();
                             input.setSpeed(value);
                         }
 
@@ -481,22 +521,22 @@ public class ShutdownService {
         }
     }
 
-    private void updateAndAddStatus( ProEconWindturbineStatus status) throws Exception {
-        status.setStartTime(date);
+    private void updateAndAddStatus( ProEconWindturbineStatus pewstatus) throws Exception {
+        pewstatus.setStartTime(date);
 
         List<PointData> speedDataList1;
 
 
-        if (windTurbines.get(status.getWindturbineId()).getWindpowerstationId().contains("GDC"))
+        if (windTurbines.get(pewstatus.getWindturbineId()).getWindpowerstationId().contains("GDC"))
         {
-            String point=gzdpointMap.get(windTurbines.get(status.getWindturbineId()).getWindpowerstationId()).getNemCode();
-            speedDataList1 =edosUtil.getHistoryDatasSnap(point,status.getStopTime().getTime()/1000,status.getStartTime().getTime()/1000);
+            String point=gzdpointMap.get(windTurbines.get(pewstatus.getWindturbineId()).getWindpowerstationId()).getNemCode();
+            speedDataList1 =edosUtil.getHistoryDatasSnap(point,pewstatus.getStopTime().getTime()/1000,pewstatus.getStartTime().getTime()/1000);
 
         }
         else
         {
-            String point=speedpointMap.get(status.getWindturbineId()).getNemCode();
-            speedDataList1 =edosUtil.getHistoryDatasSnap(point,status.getStopTime().getTime()/1000,status.getStartTime().getTime()/1000);
+            String point=speedpointMap.get(pewstatus.getWindturbineId()).getNemCode();
+            speedDataList1 =edosUtil.getHistoryDatasSnap(point,pewstatus.getStopTime().getTime()/1000,pewstatus.getStartTime().getTime()/1000);
 
 
         }
@@ -504,84 +544,159 @@ public class ShutdownService {
 
         if (speedDataList1 != null && speedDataList1.size() > 0)
         {
-            status.setSpeed(speedDataList1.get(0).getPointValueInDouble());
+            pewstatus.setSpeed(speedDataList1.get(0).getPointValueInDouble());
             DoubleSummaryStatistics summaryStatistics=speedDataList1.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
-            status.setAvgSpeed(summaryStatistics.getAverage());
+            pewstatus.setAvgSpeed(summaryStatistics.getAverage());
         }
         else
         {
-            status.setSpeed(0.0);
-            status.setAvgSpeed(0.0);
+            pewstatus.setSpeed(0.0);
+            pewstatus.setAvgSpeed(0.0);
         }
 
-        double timehour=DateUtils.hoursDiff2(date,status.getStopTime());
-        status.setStopHours(timehour);
+        double timehour=DateUtils.hoursDiff2(date,pewstatus.getStopTime());
+        pewstatus.setStopHours(timehour);
 
-        ProEconShutdownEvent shutdwonEvent = new ProEconShutdownEvent();
-        ProEconInterruption interrup = new ProEconInterruption();
-           // #region 新增 shutdownevent2 实时
-        ProEconShutdownEvent2 shutdwonEvent2 = new ProEconShutdownEvent2();
+        ProEconShutdownEvent shutdwonEvent = null;
+        ProEconInterruption interrup = null;
+        // #region 新增 shutdownevent2 实时
+        ProEconShutdownEvent2 shutdwonEvent2  = null;
 
 
-        ProEconWindturbineStatus newStatusItem = buildWindturbineStatus(status.getWindturbineId(), date,  shutdwonEvent,  interrup,  shutdwonEvent2);
-
-        proEconWindturbineStatusService.save(newStatusItem);
 
+        ProEconWindturbineStatus retValue = new ProEconWindturbineStatus();
 
-        Integer oldStatus = status.getSatusCode();
-        Integer currentStatus = this.status.get(status.getWindturbineId());
+        retValue.setProjectId(windTurbines.get(pewstatus.getWindturbineId()).getProjectId());
+        retValue.setSatusCode(status.get(pewstatus.getWindturbineId()));
+        retValue.setStatusDesc(statusDescription.get(status.get(pewstatus.getWindturbineId())));
+        retValue.setStopTime(date);
+        retValue.setWindpowerstationId(windTurbines.get(pewstatus.getWindturbineId()).getWindpowerstationId());
+        retValue.setWindturbineId(pewstatus.getWindturbineId());
 
+        Integer currentStatus = status.get(pewstatus.getWindturbineId());
         if (currentStatus == 4 || currentStatus == 6)
         {
-            if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
+            shutdwonEvent=new ProEconShutdownEvent();
+            shutdwonEvent.setId(StringUtils.getUUID());
+            shutdwonEvent.setProjectId(retValue.getProjectId());
+            shutdwonEvent.setStatusCode(currentStatus);
+            shutdwonEvent.setStopTime(date);
+            shutdwonEvent.setWindpowerstationId(retValue.getWindpowerstationId());
+            shutdwonEvent.setWindturbineId(pewstatus.getWindturbineId());
+
+
+            shutdwonEvent2=new ProEconShutdownEvent2();
+            shutdwonEvent2.setId(StringUtils.getUUID());
+            shutdwonEvent2.setProjectId(retValue.getProjectId());
+            shutdwonEvent2.setStatusCode(currentStatus);
+            shutdwonEvent2.setStopTime(date);
+            shutdwonEvent2.setWinpowerstationId(retValue.getWindpowerstationId());
+            shutdwonEvent2.setWindturbineId(pewstatus.getWindturbineId());
+
+            if (currentStatus == 4)
+            {
+
+                Date begin =DateUtils.addMinutes(date,-5);
+                Date end = DateUtils.addMinutes(date,5);
+                shutdwonEvent.setStoptypeId("gzbmq");
+                shutdwonEvent2.setStopTypeId("gzbmq");
+                //读取报警记录表前后五分钟数据,选取第一个报警报警类型
+                String str =newMethod( pewstatus.getWindturbineId(), begin, end);
+                if (StringUtils.notEmp(pewstatus.getWindturbineId()))
+                {
+
+                    shutdwonEvent.setStoptypeId(pewstatus.getWindturbineId());
+                    shutdwonEvent2.setStopTypeId(pewstatus.getWindturbineId());
+
+                }
+            }
+            else
             {
-                proEconShutdownEventService.save(shutdwonEvent);
+                shutdwonEvent.setStoptypeId("wh");
+                shutdwonEvent2.setStopTypeId("wh");
 
             }
+            retValue.setShutdownEventId(shutdwonEvent.getId());
         }
-        if (currentStatus == 12 && oldStatus != 12)
+        if (currentStatus == 12)
         {
-            proEconInterruptionService.save(interrup);
-
+            interrup=new ProEconInterruption();
+            interrup.setProjectId(retValue.getProjectId());
+            interrup.setStopTime(date);
+            interrup.setWindpowerstationId(retValue.getWindpowerstationId());
+            interrup.setWindturbineId(pewstatus.getWindturbineId());
         }
-        // 新增 shutdownevent2 实时
-        if (currentStatus == 4 || currentStatus == 6)
-        {
-            if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
-            {
-                Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-30);
-                Date dtend = shutdwonEvent2.getStopTime();
-                String windTurbineId = shutdwonEvent2.getWindturbineId();
 
-                Optional<ProEconShutdownEvent2> olditem= proEconShutdownEvent2Service.list().stream()
-                        .filter(i -> i.getWindturbineId().equals(windTurbineId)
-                                && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
-                                && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
+
+        proEconWindturbineStatusService.save(retValue);
 
 
-                        ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
+        Integer oldStatus = pewstatus.getSatusCode();
+        Integer newStatus = status.get(pewstatus.getWindturbineId());
 
-                ProEconShutdownEvent2 temp;
-                if (!olditem.isPresent())
+        if (shutdwonEvent != null)
+        {
+            if (newStatus == 4 || newStatus == 6)
+            {
+                if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
                 {
-                    proEconShutdownEvent2Service.save(shutdwonEvent2);
+                    proEconShutdownEventService.save(shutdwonEvent);
 
                 }
-                else
+            }
+        }
+
+        if (interrup != null)
+        {
+            if (newStatus == 12 && oldStatus != 12)
+            {
+                proEconInterruptionService.save(interrup);
+
+            }
+        }
+
+        if (shutdwonEvent2 != null)
+        {
+            // 新增 shutdownevent2 实时
+            if (newStatus == 4 || newStatus == 6)
+            {
+                if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
                 {
-                    temp=olditem.get();
-                    temp.setStartTime(null);
-                    if (!oldShutdownEvent2.containsKey(temp.getWindturbineId()))
-                        oldShutdownEvent2.put(temp.getWindturbineId(), temp);
+                    Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-30);
+                    Date dtend = shutdwonEvent2.getStopTime();
+                    String windTurbineId = shutdwonEvent2.getWindturbineId();
+
+                    Optional<ProEconShutdownEvent2> olditem= proEconShutdownEvent2Service.list().stream()
+                            .filter(i -> i.getWindturbineId().equals(windTurbineId)
+                                    && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
+                                    && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
+
+
+                            ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
+
+                    ProEconShutdownEvent2 temp;
+                    if (!olditem.isPresent())
+                    {
+                        proEconShutdownEvent2Service.save(shutdwonEvent2);
+
+                    }
+                    else
+                    {
+                        temp=olditem.get();
+                        temp.setStartTime(null);
+                        if (!oldShutdownEvent2.containsKey(temp.getWindturbineId()))
+                            oldShutdownEvent2.put(temp.getWindturbineId(), temp);
+                    }
                 }
             }
         }
 
+
         if (oldStatus == 4 || oldStatus == 6)
         {
-            if (currentStatus == 0 || currentStatus == 1 || currentStatus == 12)
+            if (newStatus == 0 || newStatus == 1 || newStatus == 12)
             {
-                ProEconShutdownEvent ose = oldShutdownEvent.get(status.getWindturbineId());
+                ProEconShutdownEvent ose = oldShutdownEvent.get(pewstatus.getWindturbineId());
                 if (ose != null)
                 {
                     ose.setStartTime(date);
@@ -591,10 +706,10 @@ public class ShutdownService {
 
                     if (!ose.getStoptypeId().equals("wh"))
                     {
-                        String s =newMethod( status.getWindturbineId(), DateUtils.addMinutes(ose.getStopTime(),-5), date);
-                        if (StringUtils.notEmp(s))
+                        String windturbineId =newMethod( pewstatus.getWindturbineId(), DateUtils.addMinutes(ose.getStopTime(),-5), date);
+                        if (StringUtils.notEmp(windturbineId))
                         {
-                            ose.setStoptypeId(s);
+                            ose.setStoptypeId(windturbineId);
 
                         }
                     }
@@ -602,8 +717,8 @@ public class ShutdownService {
                     //Double gc = calcLossPower(ose.WINDTURBINEID, ose.STOPTIME.Value, ose.STARTTIME.Value, ose.STOPHOURS.Value, entities);
                     //ose.LOSSPOWER = gc;
                 }
-               //  新增 shutdownevent2 实时
-                ProEconShutdownEvent2 ose2 = oldShutdownEvent2.get(status.getWindturbineId());
+                //  新增 shutdownevent2 实时
+                ProEconShutdownEvent2 ose2 = oldShutdownEvent2.get(pewstatus.getWindturbineId());
                 if (ose2 != null  )
                 {
 
@@ -621,9 +736,9 @@ public class ShutdownService {
 
             }
         }
-        if (oldStatus == 12 && currentStatus != 12)
+        if (oldStatus == 12 && newStatus != 12)
         {
-            ProEconInterruption item = oldInterrup.get(status.getWindturbineId());
+            ProEconInterruption item = oldInterrup.get(pewstatus.getWindturbineId());
             if (item != null)
             {
                 item.setStartTime(date);
@@ -744,74 +859,7 @@ public class ShutdownService {
 
 
 
-    // 新增 shutdownevent2 实时
-    private ProEconWindturbineStatus buildWindturbineStatus(String windturbineId, Date date,  ProEconShutdownEvent shutdwonEvent,
-                                                      ProEconInterruption interrup,  ProEconShutdownEvent2 shutdwonEvent2)
-    {
-
-        ProEconWindturbineStatus retValue = new ProEconWindturbineStatus();
-
-        retValue.setProjectId(windTurbines.get(windturbineId).getProjectId());
-        retValue.setSatusCode(status.get(windturbineId));
-        retValue.setStatusDesc(statusDescription.get(status.get(windturbineId)));
-        retValue.setStopTime(date);
-        retValue.setWindpowerstationId(windTurbines.get(windturbineId).getWindpowerstationId());
-        retValue.setWindturbineId(windturbineId);
-
-        Integer currentStatus = status.get(windturbineId);
-        if (currentStatus == 4 || currentStatus == 6)
-        {
 
-            shutdwonEvent.setId(StringUtils.getUUID());
-            shutdwonEvent.setProjectId(retValue.getProjectId());
-            shutdwonEvent.setStatusCode(currentStatus);
-            shutdwonEvent.setStopTime(date);
-            shutdwonEvent.setWindpowerstationId(retValue.getWindpowerstationId());
-            shutdwonEvent.setWindturbineId(windturbineId);
-
-
-
-            shutdwonEvent2.setId(StringUtils.getUUID());
-            shutdwonEvent2.setProjectId(retValue.getProjectId());
-            shutdwonEvent2.setStatusCode(currentStatus);
-            shutdwonEvent2.setStopTime(date);
-            shutdwonEvent2.setWinpowerstationId(retValue.getWindpowerstationId());
-            shutdwonEvent2.setWindturbineId(windturbineId);
-
-            if (currentStatus == 4)
-            {
-                Date begin =DateUtils.addMinutes(date,-5);
-                Date end = DateUtils.addMinutes(date,5);
-                shutdwonEvent.setStoptypeId("gzbmq");
-                shutdwonEvent2.setStopTypeId("gzbmq");
-                //读取报警记录表前后五分钟数据,选取第一个报警报警类型
-                String s =newMethod( windturbineId, begin, end);
-                if (StringUtils.notEmp(s))
-                {
-
-                    shutdwonEvent.setStoptypeId(s);
-                    shutdwonEvent2.setStopTypeId(s);
-
-                }
-            }
-            else
-            {
-                shutdwonEvent.setStoptypeId("wh");
-                shutdwonEvent2.setStopTypeId("wh");
-
-            }
-            retValue.setShutdownEventId(shutdwonEvent.getId());
-        }
-        if (currentStatus == 12)
-        {
-
-            interrup.setProjectId(retValue.getProjectId());
-            interrup.setStopTime(date);
-            interrup.setWindpowerstationId(retValue.getWindpowerstationId());
-            interrup.setWindturbineId(windturbineId);
-        }
-        return retValue;
-    }
 
     //TODO-SL 需要添加报警记录关联停机事件方法
 

+ 612 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java

@@ -0,0 +1,612 @@
+package com.gyee.generation.service;
+
+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 org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class ShutdownnewService {
+
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+    @Resource
+    private IProEconWindturbineStatusService proEconWindturbineStatusService;
+
+    @Resource
+    private IProEconShutdownEventService proEconShutdownEventService;
+
+    @Resource
+    private IProEconShutdownEvent2Service proEconShutdownEvent2Service;
+    @Resource
+    private IProEconInterruptionService proEconInterruptionService;
+
+
+
+    public static Logger logger = LoggerFactory.getLogger(ShutdownnewService.class);
+    /// 风机状态说明,key为状态码,value为状态说明
+    public Map<Integer, String> statusDescriptionMap = new HashMap<>();
+    /// 风机当前状态,key为风机编号
+    public Map<String, List<PointData>> statusMap = new HashMap<>();
+
+    Map<String, ProEconWindturbineStatus> oldStatusMap = new HashMap<>();
+    Map<String, ProEconShutdownEvent> oldShutdownEvent = new HashMap<>();
+    Map<String, ProEconInterruption> oldInterrup = new HashMap<>();
+    Map<String, ProEconShutdownEvent2> oldShutdownEvent2 = new HashMap<>();
+
+
+
+
+    public void execShutdown(Date recordDate) throws Exception {
+
+        Date begin = DateUtils.addDays(DateUtils.truncDay(recordDate), -5);
+
+
+        Date end = recordDate;
+        oldStatusMap.clear();
+        oldShutdownEvent.clear();
+        oldInterrup.clear();
+        oldShutdownEvent2.clear();
+
+        statusDescriptionMap.put(0, "待机");
+        statusDescriptionMap.put(1, "手动停机");
+        statusDescriptionMap.put(2, "正常发电");
+        statusDescriptionMap.put(3, "缺陷降出力");
+        statusDescriptionMap.put(4, "故障停机");
+        statusDescriptionMap.put(5, "故障受累");
+        statusDescriptionMap.put(6, "检修停机");
+        statusDescriptionMap.put(7, "检修受累");
+        statusDescriptionMap.put(8, "限电降出力");
+        statusDescriptionMap.put(9, "限电停机");
+        statusDescriptionMap.put(10, "电网受累");
+        statusDescriptionMap.put(11, "环境受累");
+        statusDescriptionMap.put(12, "通讯中断");
+        statusDescriptionMap.put(13, "设备离线");
+
+        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);
+            }
+
+            //初始化将所有风机编号作为key,value全部赋值为null
+            oldStatusMap.put(wt.getId(), null);
+            oldShutdownEvent.put(wt.getId(), null);
+            oldInterrup.put(wt.getId(), null);
+            oldShutdownEvent2.put(wt.getId(), null);
+        }
+//******************************************************************************************************/
+
+        //读取数据库存在的恢复时间为NULL的数据,并通过风机编号把数据遍历到对应的map
+        List<ProEconWindturbineStatus> oldStatusQuery=proEconWindturbineStatusService.list().stream()
+                .filter(i->StringUtils.empty(i.getStartTime()))
+                .sorted(Comparator.comparing(ProEconWindturbineStatus::getStopTime)).collect(Collectors.toList());
+
+        for (ProEconWindturbineStatus oldStatus : oldStatusQuery)
+        {
+            if (oldStatusMap.containsKey(oldStatus.getWindturbineId()))
+            {
+                oldStatusMap.put(oldStatus.getWindturbineId(),oldStatus);
+            }
+        }
+
+        List<ProEconShutdownEvent> oldShutdwonQuery=proEconShutdownEventService.list().stream()
+                .filter(i->StringUtils.empty(i.getStartTime()))
+                .sorted(Comparator.comparing(ProEconShutdownEvent::getStopTime)).collect(Collectors.toList());
+
+        for (ProEconShutdownEvent shutdown : oldShutdwonQuery)
+        {
+            if (oldShutdownEvent.containsKey(shutdown.getWindturbineId()))
+            {
+                oldShutdownEvent.put(shutdown.getWindturbineId(),shutdown);
+            }
+        }
+
+        List<ProEconInterruption> oldInterrupQuery=proEconInterruptionService.list().stream()
+                .filter(i->StringUtils.empty(i.getStartTime()))
+                .sorted(Comparator.comparing(ProEconInterruption::getStopTime)).collect(Collectors.toList());
+
+        for (ProEconInterruption interrup : oldInterrupQuery)
+        {
+            if (oldInterrup.containsKey(interrup.getWindturbineId()))
+            {
+                oldInterrup.put(interrup.getWindturbineId(),interrup);
+            }
+        }
+
+        List<ProEconShutdownEvent2> oldShutdwonQuery2=proEconShutdownEvent2Service.list().stream()
+                .filter(i->StringUtils.empty(i.getStartTime()))
+                .sorted(Comparator.comparing(ProEconShutdownEvent2::getStopTime)).collect(Collectors.toList());
+
+        for (ProEconShutdownEvent2 shutdown : oldShutdwonQuery2)
+        {
+            if (oldShutdownEvent2.containsKey(shutdown.getWindturbineId()))
+            {
+
+
+                oldShutdownEvent2.put(shutdown.getWindturbineId(),shutdown);
+            }
+        }
+//******************************************************************************************************/
+        //遍历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);
+
+                        if (currentStatus == 4)
+                        {
+
+//                        Date begin = DateUtils.addMinutes(date,-5);
+//                        Date end = DateUtils.addMinutes(date,5);
+                            shutdwonEvent.setStoptypeId("gzbmq");
+                            shutdwonEvent2.setStopTypeId("gzbmq");
+                            //读取报警记录表前后五分钟数据,选取第一个报警报警类型
+
+                            // String stopTypeId =newMethod( windturbineId, begin, end);
+                            String stopTypeId=null;
+                            if (StringUtils.notEmp(stopTypeId))
+                            {
+
+                                shutdwonEvent.setStoptypeId(stopTypeId);
+                                shutdwonEvent2.setStopTypeId(stopTypeId);
+
+                            }
+                        }
+                        else
+                        {
+                            shutdwonEvent.setStoptypeId("wh");
+                            shutdwonEvent2.setStopTypeId("wh");
+
+                        }
+                        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);
+                        finishWindturbineStatus(windturbineId, item, currentStatus, currentTime);
+                        oldStatusMap.put(windturbineId,null);
+                        item=null;
+
+                    }
+
+
+                    if(oldShutdownEvent.containsKey(windturbineId))
+                    {
+                        shutdwonEvent=oldShutdownEvent.get(windturbineId);
+                        shutdwonEvent = finishShutdownEvent(windturbineId, shutdwonEvent, currentStatus, currentTime);
+
+                    }
+                    if(oldInterrup.containsKey(windturbineId))
+                    {
+
+                        interrup=oldInterrup.get(windturbineId);
+                        interrup = finishInterruption(windturbineId, interrup, currentStatus, currentTime);
+                    }
+
+                    if(oldShutdownEvent2.containsKey(windturbineId))
+                    {
+                        shutdwonEvent2=oldShutdownEvent2.get(windturbineId);
+
+                        shutdwonEvent2 = finishShutdownEvent2(windturbineId, shutdwonEvent2, currentStatus, currentTime);
+                    }
+
+                    lastStatus=currentStatus;
+                }
+
+
+
+            }
+            //循环结束落盘,并清空
+            if(oldStatusMap.containsKey(windturbineId))
+            {
+                //获取数据库查询是否有风机对应时间的记录,如果没有写入数据库
+                item=oldStatusMap.get(windturbineId);
+                ProEconWindturbineStatus finalItem = item;
+               List<ProEconWindturbineStatus> ls= proEconWindturbineStatusService.list().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);
+
+                ProEconShutdownEvent finalShutdwonEvent = shutdwonEvent;
+                List<ProEconShutdownEvent> ls= proEconShutdownEventService.list().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);
+
+                ProEconInterruption finalInterrup = interrup;
+                List<ProEconInterruption> ls= proEconInterruptionService.list().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);
+
+                ProEconShutdownEvent2 finalShutdwonEvent1 = shutdwonEvent2;
+                List<ProEconShutdownEvent2> ls= proEconShutdownEvent2Service.list().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);
+                }
+            }
+
+        }
+
+//******************************************************************************************************/
+
+
+    }
+
+    private ProEconShutdownEvent finishShutdownEvent(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);
+
+
+            proEconShutdownEventService.saveOrUpdate(shutdwonEvent);
+            oldShutdownEvent.put(windturbineId,null);
+            shutdwonEvent =null;
+//        }
+        return shutdwonEvent;
+    }
+
+    private ProEconInterruption finishInterruption(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);
+
+
+            proEconInterruptionService.saveOrUpdate(interrup);
+            oldInterrup.put(windturbineId,null);
+            interrup =null;
+//        }
+        return interrup;
+    }
+
+    private ProEconShutdownEvent2 finishShutdownEvent2(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);
+            }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);
+                    c.add(Calendar.DAY_OF_MONTH,1);
+                }
+            }
+
+
+            shutdwonEvent2 =null;
+            oldShutdownEvent2.put(windturbineId,null);
+//        }
+        return shutdwonEvent2;
+    }
+
+    private void finishWindturbineStatus(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);
+
+            proEconWindturbineStatusService.saveOrUpdate(item);
+        }
+    }
+
+    private static void initalInterruption(String windturbineId, ProEconWindturbineStatus item, Date stopTime, ProEconInterruption interrup) {
+        interrup.setProjectId(item.getProjectId());
+        interrup.setStopTime(stopTime);
+        interrup.setWindpowerstationId(item.getWindpowerstationId());
+        interrup.setWindturbineId(windturbineId);
+    }
+
+    private static void initalShutdownEvent2(String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date stopTime, ProEconShutdownEvent2 shutdwonEvent2) {
+        shutdwonEvent2.setId(StringUtils.getUUID());
+        shutdwonEvent2.setProjectId(item.getProjectId());
+        shutdwonEvent2.setStatusCode(currentStatus);
+        shutdwonEvent2.setStopTime(stopTime);
+        shutdwonEvent2.setWinpowerstationId(item.getWindpowerstationId());
+        shutdwonEvent2.setWindturbineId(windturbineId);
+    }
+
+    private static void initalShutdownEvent(String windturbineId, ProEconWindturbineStatus item, Integer currentStatus, Date stopTime, ProEconShutdownEvent shutdwonEvent) {
+        shutdwonEvent.setId(StringUtils.getUUID());
+        shutdwonEvent.setProjectId(item.getProjectId());
+        shutdwonEvent.setStatusCode(currentStatus);
+        shutdwonEvent.setStopTime(stopTime);
+        shutdwonEvent.setWindpowerstationId(item.getWindpowerstationId());
+        shutdwonEvent.setWindturbineId(windturbineId);
+    }
+
+    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.truncDay(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;
+
+    }
+
+}
+
+
+
+
+
+
+

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

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author shilin
- * @since 2022-10-31
+ * @since 2022-11-12
  */
 public interface IProBasicPowerstationService extends IService<ProBasicPowerstation> {
 

+ 1 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProBasicPowerstationServiceImpl.java

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
  * </p>
  *
  * @author shilin
- * @since 2022-10-31
+ * @since 2022-11-12
  */
 @Service
 public class ProBasicPowerstationServiceImpl extends ServiceImpl<ProBasicPowerstationMapper, ProBasicPowerstation> implements IProBasicPowerstationService {

+ 2 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/service/initialpoint/InitialPointGoldenXkByEqService.java

@@ -183,10 +183,10 @@ public class InitialPointGoldenXkByEqService implements IinitialPoint {
                 allpoints.addAll(points);
                 // windPowerstationTestingPointService.insertBatch(points);
 
-                /*******************************************风电测点生成*******************************************************/
+//*******************************************风电测点生成*******************************************************/
 
 
-/*********************************************光伏测点生成*****************************************************/
+//*********************************************光伏测点生成*****************************************************/
 
                 points=new ArrayList<>();
                 for(int i=0;i<gfpointls.size();i++)

+ 3 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/util/DateUtils.java

@@ -275,7 +275,9 @@ public class DateUtils {
     public static int daysDiff(Date d1, Date d2) {
         return (int) Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (60 * 60 * 24 * 1000));
     }
-
+    public static int daysDiff1(Date d1, Date d2) {
+        return (int) Math.ceil(Math.abs((d1.getTime() - d2.getTime())) / (60 * 60 * 24 * 1000));
+    }
     /**
      * 计算两个时间之间差的小时数(取整后)
      * 

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

@@ -88,7 +88,7 @@ logging:
 db:
   url: http://10.81.3.152:8011/ts
 #参与计算的场站
-runWindpowerstation: HN_GDDL_HZJ_GDC_STA,HN_GDDL_MHS_FDC_STA,HN_LYDL_MCH_GDC_STA,HN_LYDL_NSS_FDC_STA
+runWindpowerstation: SD_GDDL_RZLX_FDC_STA,SD_GDDL_QDJN_FDC_STA,SD_GDDL_WHWD_FDC_STA,SD_GDDL_WHXQ_FDC_STA,SD_GDDL_RZWL_FDC_STA,SD_GDDL_WFZC_FDC_STA,SD_GDDL_DZXJ_FDC_STA,SD_GDDL_XTTA_FDC_STA,SD_GDDL_BH1_FDC_STA,SD_GDDL_BH2_FDC_STA,SD_GDDL_CG_FDC_STA,SD_GDDL_FJ_FDC_STA,SD_GDDL_YS_FDC_STA,SD_GDDL_FXFC_FDC_STA,SD_GDDL_JNSS_FDC_STA,SD_GDDL_WFBH_FDC_STA,SD_GDDL_PLHS_FDC_STA,SD_GDDL_JNCQ_FDC_STA,SD_GDDL_LXLN_FDC_STA,SD_GDDL_LQJS_FDC_STA,SD_GDDL_ZYXD_FDC_STA,SD_GDDL_ZYFS_FDC_STA
 #计算状态用ai或者di
 clauStatus:
   ai: GJY03_GC,YLZ01_GC,PTZ02_GC   #配置期次

+ 49 - 0
realtime/generationXK-service/src/test/java/com/gyee/generation/PgCalTest.java

@@ -0,0 +1,49 @@
+package com.gyee.generation;
+
+import com.gyee.generation.service.*;
+import org.junit.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+@SpringBootTest
+public class PgCalTest {
+    @Resource
+    private InputOrOutPutService inputOrOutPutService;
+    @Resource
+    private LimitEventService limitEventService;
+    @Resource
+    private PowerCurveFittingService powerCurveFittingService;
+    @Resource
+    private ShutdownService shutdownService;
+    @Resource
+    private WindPowerInfo1Service windPowerInfo1Service;
+    @Resource
+    private WindPowerInfo2Service windPowerInfo2Service;
+    @Resource
+    private WindPowerInfo3Service windPowerInfo3Service;
+    @Resource
+    private WindPowerInfo4Service windPowerInfo4Service;
+    @Resource
+    private WindPowerInfo5Service windPowerInfo5Service;
+    @Resource
+    private WindPowerInfo6Service windPowerInfo6Service;
+    @Resource
+    private EquipmentInfo1Service equipmentInfo1Service;
+    @Resource
+    private EquipmentInfo2Service equipmentInfo2Service;
+    @Resource
+    private EquipmentInfo3Service equipmentInfo3Service;
+    @Resource
+    private EquipmentInfo4Service equipmentInfo4Service;
+    @Resource
+    private EquipmentInfo5Service equipmentInfo5Service;
+    @Resource
+    private EquipmentInfoDayTopService equipmentInfoDayTopService;
+
+    @Test
+    public void test1() throws Exception {
+        inputOrOutPutService.inputOrOutput(new Date());
+    }
+}