ソースを参照

修改场站1、2、3、4、5、6表写入事件

shilin 2 年 前
コミット
b306cdf463
24 ファイル変更3137 行追加3801 行削除
  1. 62 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java
  2. 20 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/controller/ProEconWindturbineGoodnessController.java
  3. 16 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/mapper/auto/ProEconWindturbineGoodnessMapper.java
  4. 3 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconStateTransitionRates.java
  5. 82 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconWindturbineGoodness.java
  6. 5 6
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/CoefficientService.java
  7. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo1Service.java
  8. 1 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo2Service.java
  9. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo3Service.java
  10. 42 38
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo4Service.java
  11. 200 847
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo5Service.java
  12. 39 24
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java
  13. 158 173
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/TimelinessRateService.java
  14. 612 755
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo1Service.java
  15. 454 511
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo2Service.java
  16. 352 411
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo3Service.java
  17. 459 435
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo4Service.java
  18. 254 296
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo5Service.java
  19. 225 257
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo6Service.java
  20. 71 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java
  21. 16 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconWindturbineGoodnessService.java
  22. 20 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconWindturbineGoodnessServiceImpl.java
  23. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/initialpoint/InitialPointGoldenXkByEqService.java
  24. 43 43
      realtime/generationXK-service/src/main/java/com/gyee/generation/util/realtimesource/EdosUtil.java

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

@@ -1,9 +1,14 @@
 package com.gyee.generation;
 
+import com.gyee.generation.service.EquipmentInfo5Service;
+import com.gyee.generation.util.DateUtils;
+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.Date;
+
 /**
  * @ClassName : GenerationMain
  * @Author : xieshengjie
@@ -48,6 +53,63 @@ public class GenerationMain {
 //        {
 //            inputOrOutPutService.inputOrOutputSpeed(new Date());
 //        }
+//        WindPowerInfo1Service windPowerInfo1Service= SpringUtils.getBean("windPowerInfo1Service");
+//
+//
+        Date date =new Date();
+//        windPowerInfo1Service.calLineInfoDay(date);
+//        windPowerInfo1Service.calProjectInfoDay(date);
+//        windPowerInfo1Service.calWindpowerInfoDay(date);
+//        windPowerInfo1Service.calCompanyInfoDay(date);
+//        windPowerInfo1Service.calRegionInfoDay(date);
+//
+//        WindPowerInfo2Service windPowerInfo2Service= SpringUtils.getBean("windPowerInfo2Service");
+//        windPowerInfo2Service.calLineInfoDay(date);
+//        windPowerInfo2Service.calProjectInfoDay(date);
+//        windPowerInfo2Service.calWindpowerInfoDay(date);
+//        windPowerInfo2Service.calCompanyInfoDay(date);
+//        windPowerInfo2Service.calRegionInfoDay(date);
+//
+//        WindPowerInfo3Service windPowerInfo3Service= SpringUtils.getBean("windPowerInfo3Service");
+//        windPowerInfo3Service.calLineInfoDay(date);
+//        windPowerInfo3Service.calProjectInfoDay(date);
+//        windPowerInfo3Service.calWindpowerInfoDay(date);
+//        windPowerInfo3Service.calCompanyInfoDay(date);
+//        windPowerInfo3Service.calRegionInfoDay(date);
+//
+//        WindPowerInfo4Service windPowerInfo4Service= SpringUtils.getBean("windPowerInfo4Service");
+//        windPowerInfo4Service.calLineInfoDay(date);
+//        windPowerInfo4Service.calProjectInfoDay(date);
+//        windPowerInfo4Service.calWindpowerInfoDay(date);
+//        windPowerInfo4Service.calCompanyInfoDay(date);
+//        windPowerInfo4Service.calRegionInfoDay(date);
+//
+//        WindPowerInfo5Service windPowerInfo5Service= SpringUtils.getBean("windPowerInfo5Service");
+//        windPowerInfo5Service.calLineInfoDay(date);
+//        windPowerInfo5Service.calProjectInfoDay(date);
+//        windPowerInfo5Service.calWindpowerInfoDay(date);
+//        windPowerInfo5Service.calCompanyInfoDay(date);
+//        windPowerInfo5Service.calRegionInfoDay(date);
+//
+//        WindPowerInfo6Service windPowerInfo6Service= SpringUtils.getBean("windPowerInfo6Service");
+//        windPowerInfo6Service.calLineInfoDay(date);
+//        windPowerInfo6Service.calProjectInfoDay(date);
+//        windPowerInfo6Service.calWindpowerInfoDay(date);
+//        windPowerInfo6Service.calCompanyInfoDay(date);
+//        windPowerInfo6Service.calRegionInfoDay(date);
 
+//        EquipmentInfo1Service equipmentInfo1Service= SpringUtils.getBean("equipmentInfo1Service");
+//        equipmentInfo1Service.calEquipmentInfoDay(date);
+//        EquipmentInfo2Service equipmentInfo2Service= SpringUtils.getBean("equipmentInfo2Service");
+//        equipmentInfo2Service.calEquipmentInfoDay(date);
+//        EquipmentInfo3Service equipmentInfo3Service= SpringUtils.getBean("equipmentInfo3Service");
+//        equipmentInfo3Service.calEquipmentInfoDay(date);
+//        EquipmentInfo4Service equipmentInfo4Service= SpringUtils.getBean("equipmentInfo4Service");
+//        equipmentInfo4Service.calEquipmentInfoDay(date);
+        EquipmentInfo5Service equipmentInfo5Service= SpringUtils.getBean("equipmentInfo5Service");
+        equipmentInfo5Service.calEquipmentInfoDay(date);
+        Date end=new Date();
+        System.out.println("执行用时"+ DateUtils.secondsDiff(date,end) +"秒");
+        System.out.println("计算完成");
     }
 }

+ 20 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/controller/ProEconWindturbineGoodnessController.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 风电机拟合优度 前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2022-11-17
+ */
+@RestController
+@RequestMapping("//pro-econ-windturbine-goodness")
+public class ProEconWindturbineGoodnessController {
+
+}

+ 16 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/mapper/auto/ProEconWindturbineGoodnessMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.mapper.auto;
+
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 风电机拟合优度 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2022-11-17
+ */
+public interface ProEconWindturbineGoodnessMapper extends BaseMapper<ProEconWindturbineGoodness> {
+
+}

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

@@ -4,10 +4,11 @@ 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 java.util.Date;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
  * 状态转换及时率表
@@ -26,7 +27,7 @@ public class ProEconStateTransitionRates extends Model {
      * 编号
      */
     @TableId(value = "ID",type = IdType.ASSIGN_ID)
-    private Integer id;
+    private Long id;
 
     /**
      * 风场编号

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

@@ -0,0 +1,82 @@
+package com.gyee.generation.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 风电机拟合优度
+ * </p>
+ *
+ * @author shilin
+ * @since 2022-11-17
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconWindturbineGoodness extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private Long id;
+
+    /**
+     * 风机编号
+     */
+    private String windturbineid;
+
+    /**
+     * 日拟合优度
+     */
+    private Double daygoodness;
+
+    /**
+     * 月拟合优度
+     */
+    private Double monthgoodness;
+
+    /**
+     * 年拟合优度
+     */
+    private Double yeargoodness;
+
+    /**
+     * 日期
+     */
+    private Date recorddate;
+
+
+    /**
+     * 风场编号
+     */
+    private String windtpowerstationid;
+
+    /**
+     * 型号编号
+     */
+    private String modelid;
+
+
+
+    /**
+     * 日功率一致性系数
+     */
+    private Double daycoefficient;
+
+    /**
+     * 月功率一致性系数
+     */
+    private Double monthcoefficient;
+
+    /**
+     * 年功率一致性系数
+     */
+    private Double yearcoefficient;
+
+
+}

+ 5 - 6
realtime/generationXK-service/src/main/java/com/gyee/generation/service/CoefficientService.java

@@ -30,21 +30,20 @@ public class CoefficientService {
 
 
     public Map<String, Map<String, Double>> coefficient(Date currentDate) throws Exception {
-        //调度时间是第二天,currentDate 是第一天
 
-        currentDate = DateUtils.truncate(currentDate);
+        Date beginDate = DateUtils.addDays(currentDate,-1);
+
 
         Calendar c = Calendar.getInstance();
-        c.setTime(currentDate);
+        c.setTime(beginDate);
 
         c.set(Calendar.DAY_OF_MONTH, 1);
         Date monthbeginDate = c.getTime();
         c.set(Calendar.MONTH, 0);
         Date yearbeginDate = c.getTime();
 
-        c.setTime(currentDate);
-        Date beginDate = c.getTime();
-        c.add(Calendar.DAY_OF_MONTH, 1);
+
+
         Date endDate = c.getTime();
 
         Map<String, Map<String, Double>> resultmap = new HashMap<>();

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

@@ -69,7 +69,7 @@ public class EquipmentInfo1Service {
                 pewp.setProjectId(wt.getProjectId());
                 pewp.setRegionId(wt.getRegionId());
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
-
+                pewp.setWindturbineId(wt.getId());
                 //昨日的统计结果
                 List<ProEconEquipmentInfoDay1> pepid1ls =new ArrayList<>();
                 Calendar cl=Calendar.getInstance();

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

@@ -67,6 +67,7 @@ public class EquipmentInfo2Service {
                 pewp.setProjectId(wt.getProjectId());
                 pewp.setRegionId(wt.getRegionId());
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
+                pewp.setWindturbineId(wt.getId());
                 //昨日的统计结果
                 List<ProEconEquipmentInfoDay2> pepidls =new ArrayList<>();
                 Calendar cl=Calendar.getInstance();

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

@@ -67,7 +67,7 @@ public class EquipmentInfo3Service {
                 pewp.setProjectId(wt.getProjectId());
                 pewp.setRegionId(wt.getRegionId());
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
-
+                pewp.setWindturbineId(wt.getId());
                 //昨日的统计结果
                 List<ProEconEquipmentInfoDay3> pepidls =new ArrayList<>();
                 Calendar cl=Calendar.getInstance();

+ 42 - 38
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo4Service.java

@@ -55,8 +55,9 @@ public class EquipmentInfo4Service {
     @Resource
     private IProEconFaultLiminatedefectsService proEconFaultLiminatedefectsService;
 
-   
 
+    @Resource
+    private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
    
     public void calEquipmentInfoDay(Date recordDate) throws Exception {
         Calendar c = Calendar.getInstance();
@@ -92,11 +93,23 @@ public class EquipmentInfo4Service {
                 peioomap.put(peioo.getWindturbineId(), peioo);
             }
         }
+        Map<String,ProEconWindturbineGoodness> wgmap=new HashMap<>();
+        List<ProEconWindturbineGoodness> wgls = proEconWindturbineGoodnessService.list().stream()
+                .filter(i -> i.getRecorddate().compareTo(DateUtils.truncate(begin))==0
+                        && CacheContext.wtmap.containsKey(i.getWindturbineid()))
+                .collect(Collectors.toList());
 
-        //功率一致性接口调用
-        Map<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
-        //拟合优度接口调用
-        Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
+        if(!wgls.isEmpty())
+        {
+            for(ProEconWindturbineGoodness wg:wgls)
+            {
+                wgmap.put(wg.getWindturbineid(),wg);
+            }
+        }
+//        //功率一致性接口调用
+//        Map<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
+//        //拟合优度接口调用
+//        Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
 
         for (ProBasicEquipment wt : CacheContext.wtls) {
             if (CacheContext.wtpAimap.containsKey(wt.getId())) {
@@ -110,7 +123,7 @@ public class EquipmentInfo4Service {
                 pewp.setProjectId(wt.getProjectId());
                 pewp.setRegionId(wt.getRegionId());
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
-
+                pewp.setWindturbineId(wt.getId());
                 //昨日的统计结果
                 List<ProEconEquipmentInfoDay4> pepidls = new ArrayList<>();
                 Calendar cl = Calendar.getInstance();
@@ -147,7 +160,7 @@ public class EquipmentInfo4Service {
                     pepid3 = pepid3ls.get(0);
                 }
 
-                calDetiall(peioomap, pewp, end, begin, wt, pepidls, pepid2, pepid3, glqxyizxMap, nhydMap);
+                calDetiall(peioomap, pewp, end, begin, wt, pepidls, pepid2, pepid3,  wgmap);
 
                 proEconEquipmentInfoDay4Service.save(pewp);
 
@@ -160,27 +173,26 @@ public class EquipmentInfo4Service {
 
     private void calDetiall(Map<String, ProEconInOrOutSpeedTotal> peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin,
                             ProBasicEquipment wt, List<ProEconEquipmentInfoDay4> pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3,
-                            Map<String, Map<String, Double>> glqxyizxMap, Map<String, Map<String, Double>> nhydMap) throws Exception {
+                            Map<String,ProEconWindturbineGoodness> wgmap) throws Exception {
 
        //*****************************************日信息统计*********************************************************/
         Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wt.getId());
 
+
+
+
         ProEconInOrOutSpeedTotal peiost;
 
         //获得功率一致性系数
-        if (glqxyizxMap.containsKey(wt.getId())) {
-            Map<String, Double> map = glqxyizxMap.get(wt.getId());
-            if (map.containsKey("day")) {
-                pewp.setRglyzxxs(map.get("day"));
-            }
+        if (wgmap.containsKey(wt.getId())) {
+            ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+            pewp.setRglyzxxs(wg.getDaycoefficient());
         }
 
         //获得拟合优度
-        if (nhydMap.containsKey(wt.getId())) {
-            Map<String, Double> map = nhydMap.get(wt.getId());
-            if (map.containsKey("day")) {
-                pewp.setRnhyd(map.get("day"));
-            }
+        if (wgmap.containsKey(wt.getId())) {
+            ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+            pewp.setRnhyd(wg.getDaygoodness());
         }
 
         if (StringUtils.notEmp(pepid2)) {
@@ -397,19 +409,15 @@ public class EquipmentInfo4Service {
 
 
             //获得功率一致性系数
-            if (glqxyizxMap.containsKey(wt.getId())) {
-                Map<String, Double> map = glqxyizxMap.get(wt.getId());
-                if (map.containsKey("month")) {
-                    pewp.setYglyzxxs(map.get("month"));
-                }
+            if (wgmap.containsKey(wt.getId())) {
+                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+                pewp.setYglyzxxs(wg.getMonthcoefficient());
             }
 
             //获得拟合优度
-            if (nhydMap.containsKey(wt.getId())) {
-                Map<String, Double> map = nhydMap.get(wt.getId());
-                if (map.containsKey("month")) {
-                    pewp.setYnhyd(map.get("month"));
-                }
+            if (wgmap.containsKey(wt.getId())) {
+                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+                pewp.setYnhyd(wg.getMonthgoodness());
             }
 
             if (StringUtils.notEmp(pepid2)) {
@@ -589,19 +597,15 @@ public class EquipmentInfo4Service {
 
 
             //获得功率一致性系数
-            if (glqxyizxMap.containsKey(wt.getId())) {
-                Map<String, Double> map = glqxyizxMap.get(wt.getId());
-                if (map.containsKey("year")) {
-                    pewp.setNglyzxxs(map.get("year"));
-                }
+            if (wgmap.containsKey(wt.getId())) {
+                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+                pewp.setNglyzxxs(wg.getYearcoefficient());
             }
 
             //获得拟合优度
-            if (nhydMap.containsKey(wt.getId())) {
-                Map<String, Double> map = nhydMap.get(wt.getId());
-                if (map.containsKey("year")) {
-                    pewp.setNnhyd(map.get("year"));
-                }
+            if (wgmap.containsKey(wt.getId())) {
+                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
+                pewp.setNnhyd(wg.getYeargoodness());
             }
 
             if (StringUtils.notEmp(pepid2)) {

ファイルの差分が大きいため隠しています
+ 200 - 847
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo5Service.java


+ 39 - 24
realtime/generationXK-service/src/main/java/com/gyee/generation/service/ShutdownnewService.java

@@ -190,31 +190,7 @@ public class ShutdownnewService {
                         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)
@@ -526,6 +502,25 @@ public class ShutdownnewService {
         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) {
@@ -536,6 +531,26 @@ public class ShutdownnewService {
         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) {

+ 158 - 173
realtime/generationXK-service/src/main/java/com/gyee/generation/service/TimelinessRateService.java

@@ -1,18 +1,14 @@
 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.PointVo;
 import com.gyee.generation.service.auto.*;
 import com.gyee.generation.util.DateUtils;
 import com.gyee.generation.util.StringUtils;
 import com.gyee.generation.util.realtimesource.IEdosUtil;
 import com.gyee.generation.util.statisticcs.Initial;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -24,7 +20,7 @@ import java.util.stream.Collectors;
 @Service
 public class TimelinessRateService {
 
-    private static final Logger logger = LoggerFactory.getLogger(TimelinessRateService.class);
+//    private static final Logger logger = LoggerFactory.getLogger(TimelinessRateService.class);
     @Resource
     private IEdosUtil edosUtil;
 
@@ -45,25 +41,31 @@ public class TimelinessRateService {
     @Resource
     private IProEconShutdownEventService proEconShutdownEventService;
 
+
+    public void calEquipmentInfoDay(Date currentDate) throws Exception {
+        resetRate(currentDate);
+        failRate(currentDate);
+
+    }
+
     /**
      * 复位及时率
-     * @param currentDate
      */
-    public void resetRate(Date currentDate) {
+    public void resetRate(Date currentDate) throws Exception {
         //调度时间是第二天,currentDate 是第一天
-        Date beginDate = currentDate;
         Date endDate = DateUtils.addDays(currentDate, 1);
 
 
         List<ProEconShutdownEvent2> shutdownevents = proEconShutdownEvent2Service.list().stream().filter(i ->
                 i.getWinpowerstationId().contains("FDC")
-                        && (i.getStopTime().compareTo(beginDate) == 0 || i.getStopTime().after(beginDate))
+                        && (i.getStopTime().compareTo(currentDate) == 0 || i.getStopTime().after(currentDate))
                         && (i.getStopTime().compareTo(endDate) == 0 || i.getStopTime().before(endDate))
+                        && i.getStopTypeId() != null && i.getStopHours() != null
                         && !i.getStopTypeId().equals("wh")
         ).collect(Collectors.toList());
 
 
-        Map<String, ProEconStateTransitionRates> rates = new HashMap<String, ProEconStateTransitionRates>();
+        Map<String, ProEconStateTransitionRates> rates = new HashMap<>();
 
         for (ProBasicEquipment wt : CacheContext.wtls) {
             ProEconStateTransitionRates rate = new ProEconStateTransitionRates();
@@ -136,31 +138,37 @@ public class TimelinessRateService {
                         item.setResetRate(null);
                     }
                 }
-            }
 
-            for (ProEconStateTransitionRates day : rates.values()) {
+                if (item.getStopHours() < 24) {
 
-                Optional<ProEconStateTransitionRates> dayInfoo = proEconStateTransitionRatesService.list().stream().filter(i -> i.getWindturbineId().equals(day.getWindturbineId())
-                        && i.getRecordDate().compareTo(currentDate) == 0
-                ).findFirst();
+                    double temp = rates.get(item.getWindturbineId()).getTimerate21();
+                    temp = temp + 1;
+                    rates.get(item.getWindturbineId()).setTimerate21(temp);
 
-                ProEconStateTransitionRates dayInfo = new ProEconStateTransitionRates();
-                if (dayInfoo.isPresent()) {
 
-                    dayInfo = dayInfoo.get();
-                    buildresetRate(dayInfo, day);
-                    QueryWrapper<ProEconStateTransitionRates> wrapper = new QueryWrapper<>();
-                    wrapper.eq("id", dayInfo.getId());
-                    proEconStateTransitionRatesService.remove(wrapper);
+                }
+                double temp = rates.get(item.getWindturbineId()).getTimerate22();
+                temp = temp + 1;
+                rates.get(item.getWindturbineId()).setTimerate22(temp);
 
 
-                }else
-                {
-                    dayInfo = new ProEconStateTransitionRates();
-                    buildresetRate(dayInfo, day);
-                }
+            }
+
+            stateRate(currentDate,rates);
+
+            List<Long> dayInfoids = proEconStateTransitionRatesService.list().stream().filter(i -> i.getRecordDate().compareTo(currentDate) == 0
+            ).map(ProEconStateTransitionRates::getId).collect(Collectors.toList());
+
+            ProEconStateTransitionRates dayInfo;
+            if (!dayInfoids.isEmpty()) {
+
+                proEconStateTransitionRatesService.removeByIds(dayInfoids);
+            }
+            for (ProEconStateTransitionRates day : rates.values()) {
 
+                dayInfo = new ProEconStateTransitionRates();
 
+                buildresetRate(dayInfo, day);
 
 
                 proEconStateTransitionRatesService.save(dayInfo);
@@ -177,11 +185,28 @@ public class TimelinessRateService {
         dayInfo.setProjectId(day.getProjectId());
         dayInfo.setLineId(day.getLineId());
         dayInfo.setWindturbineId(day.getWindturbineId());
+        dayInfo.setTimerate1(day.getTimerate1());
+        dayInfo.setTimerate2(day.getTimerate2());
+        dayInfo.setTimerate3(day.getTimerate3());
+        dayInfo.setTimerate4(day.getTimerate4());
+        dayInfo.setTimerate5(day.getTimerate5());
+        dayInfo.setTimerate6(day.getTimerate6());
+        dayInfo.setTimerate7(day.getTimerate7());
+        dayInfo.setTimerate8(day.getTimerate8());
+        dayInfo.setTimerate10(day.getTimerate10());
+        dayInfo.setTimerate11(day.getTimerate11());
+        dayInfo.setTimerate12(day.getTimerate12());
+        dayInfo.setTimerate13(day.getTimerate13());
+        dayInfo.setTimerate14(day.getTimerate14());
+        dayInfo.setTimerate15(day.getTimerate15());
+
         dayInfo.setTimerate16(day.getTimerate16());
         dayInfo.setTimerate17(day.getTimerate17());
         dayInfo.setTimerate18(day.getTimerate18());
         dayInfo.setTimerate19(day.getTimerate19());
         dayInfo.setTimerate20(day.getTimerate20());
+        dayInfo.setTimerate21(day.getTimerate21());
+        dayInfo.setTimerate22(day.getTimerate22());
 
     }
 
@@ -189,18 +214,13 @@ public class TimelinessRateService {
      * 状态转换及时率
      */
     Double interval = 0.33; //20分钟
-    Map<Double, Double> stateDescription1 = new HashMap<Double, Double>();
-    Map<Double, Double> stateDescription2 = new HashMap<Double, Double>();
+    Map<Double, Double> stateDescription1 = new HashMap<>();
+    Map<Double, Double> stateDescription2 = new HashMap<>();
+
 
 
+    public void stateRate(Date currentDate,Map<String, ProEconStateTransitionRates> rates) throws Exception {
 
-    public void stateRate(Date currentDate) throws Exception {
-        Map<Integer, String> statusDescription = new HashMap<Integer, String>();
-        statusDescription.put(0, "待机");
-        statusDescription.put(2, "正常发电");
-        statusDescription.put(4, "故障停机");
-        statusDescription.put(12, "通讯中断");
-        statusDescription.put(6, "检修停机");
 
 
 
@@ -221,21 +241,12 @@ public class TimelinessRateService {
         Date endDate = DateUtils.addDays(currentDate, 1);
 
 
-        Map<String, ProEconStateTransitionRates> rates = new HashMap<String, ProEconStateTransitionRates>();
-        Map<String, List<ProEconStateTranRatesSub>> ratesubs1 = new HashMap<String, List<ProEconStateTranRatesSub>>();
-        Map<String, List<ProEconStateTranRatesSub2>> ratesubs2 = new HashMap<String, List<ProEconStateTranRatesSub2>>();
+        Map<String, List<ProEconStateTranRatesSub>> ratesubs1 = new HashMap<>();
+        Map<String, List<ProEconStateTranRatesSub2>> ratesubs2 = new HashMap<>();
 
         for (ProBasicEquipment wt : CacheContext.wtls) {
-            ProEconStateTransitionRates rate = new ProEconStateTransitionRates();
-            rate.setRecordDate(currentDate);
-            rate.setWindpwoerId(wt.getWindpowerstationId());
-            rate.setProjectId(wt.getProjectId());
-            rate.setLineId(wt.getLineId());
-            rate.setWindturbineId(wt.getId());
+            ProEconStateTransitionRates rate =rates.get(wt.getId());
 
-            Initial.initial(rate);
-
-            rates.put(wt.getId(), rate);
             List<PointData> speedDataList = null;
             List<PointData> statusDataList = null;
             if (CacheContext.wtpAimap.containsKey(wt.getId())) {
@@ -254,18 +265,18 @@ public class TimelinessRateService {
 
             //List<PointData> powerDataList = getHistoryDatasSnap(powerpointDictionary[id].ID, beginDate, endDate);
 
-            List<ProEconStateTranRatesSub> subs = new ArrayList<ProEconStateTranRatesSub>();
+            List<ProEconStateTranRatesSub> subs = new ArrayList<>();
             ProEconStateTranRatesSub sub = new ProEconStateTranRatesSub();
 
             if (speedDataList != null && statusDataList != null && statusDataList.size() == speedDataList.size()) {
-                DoubleSummaryStatistics summaryStatistics = speedDataList.stream().mapToDouble(n -> n.getPointValueInDouble()).summaryStatistics();
+//                DoubleSummaryStatistics summaryStatistics = speedDataList.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+//
+//                //最大最小风速
+//                double max = summaryStatistics.getMax();
+//                double min = summaryStatistics.getMin();
 
-                //最大最小风速
-                double max = summaryStatistics.getMax();
-                double min = summaryStatistics.getMin();
 
-
-                for (Integer i = 0; i < speedDataList.size(); i++) {
+                for (int i = 0; i < speedDataList.size(); i++) {
                     if (speedDataList.get(i).getPointValueInDouble() <= 3.0) {
                         sub = buildStateRate(currentDate, wt.getId(), speedDataList, statusDataList, subs, sub, i, 3.0);
 
@@ -300,12 +311,12 @@ public class TimelinessRateService {
                 //========================================================================================================================================
                 //========================================================================================================================================
 
-                List<ProEconStateTranRatesSub2> subs2 = new ArrayList<ProEconStateTranRatesSub2>();
+                List<ProEconStateTranRatesSub2> subs2 = new ArrayList<>();
                 ProEconStateTranRatesSub2 sub2 = new ProEconStateTranRatesSub2();
 
-                Double interval1 = 0.0;
-                Double interval2 = 0.0;
-                Double interval3 = 0.0;
+                double interval1 = 0.0;
+                double interval2 = 0.0;
+                double interval3 = 0.0;
 
                 List<Date> intervaltimebegin = new ArrayList<>();
                 List<Date> intervaltimeend = new ArrayList<>();
@@ -313,7 +324,7 @@ public class TimelinessRateService {
 
                 Double lastspeed = 0.0;
 
-                for (Integer i = 0; i < subs.size(); i++) {
+                for (int i = 0; i < subs.size(); i++) {
 
 
                     if (sub2.getSpeed() == null) {
@@ -323,7 +334,7 @@ public class TimelinessRateService {
                         if (subs.get(i).getDurationHours() > interval)  //当前时间间隔满足条件
                         {
                             /* 加处理代码 */
-                            Double tempspeed = 0.0;
+                            double tempspeed;
                             if (interval1 >= interval2 && interval1 >= interval3) {
                                 tempspeed = 3.0;
                             } else if (interval2 >= interval1 && interval2 >= interval3) {
@@ -339,7 +350,7 @@ public class TimelinessRateService {
                                 /* 加处理代码 */
                             } else {
 
-                                newMethod(subs, sub2, interval1, interval2, interval3, intervaltimebegin, intervaltimeend, lastspeed, i);
+                                newMethod(sub2, interval1, interval2, interval3, intervaltimebegin, intervaltimeend);
                                 interval1 = 0.0;
                                 interval2 = 0.0;
                                 interval3 = 0.0;
@@ -372,11 +383,11 @@ public class TimelinessRateService {
 
                                 } else {
                                     interval3 = interval3 - subs.get(i).getDurationHours();
-                                    ;
+
                                 }
 
 
-                                newMethod(subs, sub2, interval1, interval2, interval3, intervaltimebegin, intervaltimeend, lastspeed, i);
+                                newMethod(sub2, interval1, interval2, interval3, intervaltimebegin, intervaltimeend);
                                 interval1 = 0.0;
                                 interval2 = 0.0;
                                 interval3 = 0.0;
@@ -436,17 +447,17 @@ public class TimelinessRateService {
 //============================================================================================================================================================================
 //============================================================================================================================================================================
 
-                for (Integer i = 0; i < subs2.size(); i++) {
+                for (ProEconStateTranRatesSub2 proEconStateTranRatesSub2 : subs2) {
 
 
-                    if (subs2.get(i).getSpeed() == 3) {
-                        if (subs2.get(i).getDurationHours() > 0.5) {
-                            if (subs2.get(i).getStatusCode() == 0 || subs2.get(i).getStatusCode() == 1) {
+                    if (proEconStateTranRatesSub2.getSpeed() == 3) {
+                        if (proEconStateTranRatesSub2.getDurationHours() > 0.5) {
+                            if (proEconStateTranRatesSub2.getStatusCode() == 0 || proEconStateTranRatesSub2.getStatusCode() == 1) {
                                 //if (subs2.get(i).getStatusCode() == 4 && subs2.get(i).getStatusCode() == 2)
                                 //{
-                                if (subs2.get(i).getStatusHours() < 0.25)//5分钟
+                                if (proEconStateTranRatesSub2.getStatusHours() < 0.25)//5分钟
                                 {
-                                    subs2.get(i).setResetRate(0.25);
+                                    proEconStateTranRatesSub2.setResetRate(0.25);
                                     double temp = rate.getTimerate1();
                                     temp = temp + 1;
                                     rate.setTimerate1(temp);
@@ -463,9 +474,9 @@ public class TimelinessRateService {
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
 
-                                } else if (subs2.get(i).getStatusHours() < 0.33)//10分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.33)//10分钟
                                 {
-                                    subs2.get(i).setResetRate(0.33);
+                                    proEconStateTranRatesSub2.setResetRate(0.33);
                                     double temp = rate.getTimerate2();
                                     temp = temp + 1;
                                     rate.setTimerate2(temp);
@@ -477,10 +488,10 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.42)//15分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.42)//15分钟
                                 {
 
-                                    subs2.get(i).setResetRate(0.42);
+                                    proEconStateTranRatesSub2.setResetRate(0.42);
                                     double temp = rate.getTimerate3();
                                     temp = temp + 1;
                                     rate.setTimerate3(temp);
@@ -488,9 +499,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.5)//20分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.5)//20分钟
                                 {
-                                    subs2.get(i).setResetRate(0.5);
+                                    proEconStateTranRatesSub2.setResetRate(0.5);
                                     double temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
@@ -504,12 +515,12 @@ public class TimelinessRateService {
                             }
 
 
-                            if (subs2.get(i).getStatusCode() == 4) {
+                            if (proEconStateTranRatesSub2.getStatusCode() == 4) {
 
-                                if (subs2.get(i).getStatusHours() < 0.25)//5分钟
+                                if (proEconStateTranRatesSub2.getStatusHours() < 0.25)//5分钟
                                 {
 
-                                    subs2.get(i).setResetRate(0.25);
+                                    proEconStateTranRatesSub2.setResetRate(0.25);
                                     double temp = rate.getTimerate5();
                                     temp = temp + 1;
                                     rate.setTimerate5(temp);
@@ -525,10 +536,10 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.33)//10分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.33)//10分钟
                                 {
 
-                                    subs2.get(i).setResetRate(0.33);
+                                    proEconStateTranRatesSub2.setResetRate(0.33);
                                     double temp = rate.getTimerate6();
                                     temp = temp + 1;
                                     rate.setTimerate6(temp);
@@ -540,9 +551,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.42)//15分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.42)//15分钟
                                 {
-                                    subs2.get(i).setResetRate(0.42);
+                                    proEconStateTranRatesSub2.setResetRate(0.42);
                                     double temp = rate.getTimerate7();
                                     temp = temp + 1;
                                     rate.setTimerate7(temp);
@@ -551,9 +562,9 @@ public class TimelinessRateService {
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
 
-                                } else if (subs2.get(i).getStatusHours() < 0.5)//20分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.5)//20分钟
                                 {
-                                    subs2.get(i).setResetRate(0.5);
+                                    proEconStateTranRatesSub2.setResetRate(0.5);
                                     double temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
@@ -568,16 +579,16 @@ public class TimelinessRateService {
 
 
                         }
-                    } else if (subs2.get(i).getSpeed() == 3.5) {
-                        if (subs2.get(i).getDurationHours() > 0.5) {
+                    } else if (proEconStateTranRatesSub2.getSpeed() == 3.5) {
+                        if (proEconStateTranRatesSub2.getDurationHours() > 0.5) {
 
 
-                            if (subs2.get(i).getStatusCode() == 0 || subs2.get(i).getStatusCode() == 1) {
+                            if (proEconStateTranRatesSub2.getStatusCode() == 0 || proEconStateTranRatesSub2.getStatusCode() == 1) {
                                 //if (subs2.get(i).getStatusCode() == 4 && subs2.get(i).getStatusCode() == 2)
                                 //{
-                                if (subs2.get(i).getStatusHours() < 0.25)//5分钟
+                                if (proEconStateTranRatesSub2.getStatusHours() < 0.25)//5分钟
                                 {
-                                    subs2.get(i).setResetRate(0.25);
+                                    proEconStateTranRatesSub2.setResetRate(0.25);
                                     double temp = rate.getTimerate1();
                                     temp = temp + 1;
                                     rate.setTimerate1(temp);
@@ -593,9 +604,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.33)//10分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.33)//10分钟
                                 {
-                                    subs2.get(i).setResetRate(0.3);
+                                    proEconStateTranRatesSub2.setResetRate(0.3);
                                     double temp = rate.getTimerate2();
                                     temp = temp + 1;
                                     rate.setTimerate2(temp);
@@ -607,9 +618,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.42)//15分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.42)//15分钟
                                 {
-                                    subs2.get(i).setResetRate(0.42);
+                                    proEconStateTranRatesSub2.setResetRate(0.42);
                                     double temp = rate.getTimerate3();
                                     temp = temp + 1;
                                     rate.setTimerate3(temp);
@@ -617,9 +628,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.5)//20分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.5)//20分钟
                                 {
-                                    subs2.get(i).setResetRate(0.5);
+                                    proEconStateTranRatesSub2.setResetRate(0.5);
                                     double temp = rate.getTimerate4();
                                     temp = temp + 1;
                                     rate.setTimerate4(temp);
@@ -631,12 +642,12 @@ public class TimelinessRateService {
                                 rate.setTimerate13(temp);
                             }
 
-                            if (subs2.get(i).getStatusCode() == 4) {
+                            if (proEconStateTranRatesSub2.getStatusCode() == 4) {
                                 //if (subs2.get(i).getStatusCode() == 0 || subs2.get(i).getStatusCode() == 1)
                                 //{
-                                if (subs2.get(i).getStatusHours() < 0.25)//5分钟
+                                if (proEconStateTranRatesSub2.getStatusHours() < 0.25)//5分钟
                                 {
-                                    subs2.get(i).setResetRate(0.25);
+                                    proEconStateTranRatesSub2.setResetRate(0.25);
                                     double temp = rate.getTimerate5();
                                     temp = temp + 1;
                                     rate.setTimerate5(temp);
@@ -652,9 +663,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.33)//10分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.33)//10分钟
                                 {
-                                    subs2.get(i).setResetRate(0.33);
+                                    proEconStateTranRatesSub2.setResetRate(0.33);
                                     double temp = rate.getTimerate6();
                                     temp = temp + 1;
                                     rate.setTimerate6(temp);
@@ -666,9 +677,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.42)//15分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.42)//15分钟
                                 {
-                                    subs2.get(i).setResetRate(0.42);
+                                    proEconStateTranRatesSub2.setResetRate(0.42);
                                     double temp = rate.getTimerate7();
                                     temp = temp + 1;
                                     rate.setTimerate7(temp);
@@ -676,9 +687,9 @@ public class TimelinessRateService {
                                     temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
-                                } else if (subs2.get(i).getStatusHours() < 0.5)//20分钟
+                                } else if (proEconStateTranRatesSub2.getStatusHours() < 0.5)//20分钟
                                 {
-                                    subs2.get(i).setResetRate(0.5);
+                                    proEconStateTranRatesSub2.setResetRate(0.5);
                                     double temp = rate.getTimerate8();
                                     temp = temp + 1;
                                     rate.setTimerate8(temp);
@@ -690,13 +701,13 @@ public class TimelinessRateService {
                                 rate.setTimerate14(temp);
                             }
                         }
-                    } else if (subs2.get(i).getSpeed() == 4) {
-                        if (subs2.get(i).getDurationHours() > 0.5) {
-                            if (subs2.get(i).getStatusCode() == 0) {
-                                if (subs2.get(i).getStatusCode() == 1) {
-                                    if (subs2.get(i).getStatusHours() < 0.25)//5分钟
+                    } else if (proEconStateTranRatesSub2.getSpeed() == 4) {
+                        if (proEconStateTranRatesSub2.getDurationHours() > 0.5) {
+                            if (proEconStateTranRatesSub2.getStatusCode() == 0) {
+                                if (proEconStateTranRatesSub2.getStatusCode() == 1) {
+                                    if (proEconStateTranRatesSub2.getStatusHours() < 0.25)//5分钟
                                     {
-                                        subs2.get(i).setResetRate(0.25);
+                                        proEconStateTranRatesSub2.setResetRate(0.25);
                                         double temp = rate.getTimerate9();
                                         temp = temp + 1;
                                         rate.setTimerate9(temp);
@@ -712,9 +723,9 @@ public class TimelinessRateService {
                                         temp = rate.getTimerate12();
                                         temp = temp + 1;
                                         rate.setTimerate12(temp);
-                                    } else if (subs2.get(i).getStatusHours() < 0.33)//10分钟
+                                    } else if (proEconStateTranRatesSub2.getStatusHours() < 0.33)//10分钟
                                     {
-                                        subs2.get(i).setResetRate(0.33);
+                                        proEconStateTranRatesSub2.setResetRate(0.33);
                                         double temp = rate.getTimerate10();
                                         temp = temp + 1;
                                         rate.setTimerate10(temp);
@@ -726,9 +737,9 @@ public class TimelinessRateService {
                                         temp = rate.getTimerate12();
                                         temp = temp + 1;
                                         rate.setTimerate12(temp);
-                                    } else if (subs2.get(i).getStatusHours() < 0.42)//15分钟
+                                    } else if (proEconStateTranRatesSub2.getStatusHours() < 0.42)//15分钟
                                     {
-                                        subs2.get(i).setResetRate(0.42);
+                                        proEconStateTranRatesSub2.setResetRate(0.42);
                                         double temp = rate.getTimerate11();
                                         temp = temp + 1;
                                         rate.setTimerate11(temp);
@@ -736,9 +747,9 @@ public class TimelinessRateService {
                                         temp = rate.getTimerate12();
                                         temp = temp + 1;
                                         rate.setTimerate12(temp);
-                                    } else if (subs2.get(i).getStatusHours() < 0.5)//20分钟
+                                    } else if (proEconStateTranRatesSub2.getStatusHours() < 0.5)//20分钟
                                     {
-                                        subs2.get(i).setResetRate(0.5);
+                                        proEconStateTranRatesSub2.setResetRate(0.5);
                                         double temp = rate.getTimerate12();
                                         temp = temp + 1;
                                         rate.setTimerate12(temp);
@@ -772,7 +783,7 @@ public class TimelinessRateService {
         }
 
         for (String key : rates.keySet()) {
-            ProEconStateTransitionRates rate = rates.get(key);
+
             if (ratesubs1.containsKey(key) && ratesubs2.containsKey(key)) {
                 for (ProEconStateTranRatesSub item : ratesubs1.get(key)) {
                     proEconStateTranRatesSubService.save(item);
@@ -781,33 +792,30 @@ public class TimelinessRateService {
                     proEconStateTranRatesSub2Service.save(item);
                 }
 
-
-                Optional<ProEconStateTransitionRates> dayInfoo = proEconStateTransitionRatesService.list().stream()
-                        .filter(i -> i.getWindturbineId().equals(key)
-                                && i.getRecordDate().compareTo(currentDate) == 0
-                        ).findFirst();
-
-                ProEconStateTransitionRates dayInfo = new ProEconStateTransitionRates();
-                if (dayInfoo.isPresent()) {
-
-                    dayInfo = dayInfoo.get();
-                    buildresetRateByState(dayInfo, rate);
-                    QueryWrapper<ProEconStateTransitionRates> wrapper = new QueryWrapper<>();
-                    wrapper.eq("id", dayInfo.getId());
-                    proEconStateTransitionRatesService.remove(wrapper);
-                }else
-                {
-                    dayInfo = new ProEconStateTransitionRates();
-                    buildresetRateByState(dayInfo, rate);
-                }
-
-                proEconStateTransitionRatesService.save(dayInfo);
             }
         }
 
+//        List<Long> dayInfoids = proEconStateTransitionRatesService.list().stream().filter(i -> i.getRecordDate().compareTo(currentDate) == 0
+//        ).map(ProEconStateTransitionRates::getId).collect(Collectors.toList());
+//
+//        ProEconStateTransitionRates dayInfo;
+//        if (!dayInfoids.isEmpty()) {
+//
+//            proEconStateTransitionRatesService.removeByIds(dayInfoids);
+//        }
+//        for (ProEconStateTransitionRates day : rates.values()) {
+//
+//            dayInfo = new ProEconStateTransitionRates();
+//
+//            buildresetRate(dayInfo, day);
+//
+//
+//            proEconStateTransitionRatesService.save(dayInfo);
+//        }
+
     }
 
-    private static void newMethod(List<ProEconStateTranRatesSub> subs, ProEconStateTranRatesSub2 sub2, Double interval1, Double interval2, Double interval3, List<Date> intervaltimebegin, List<Date> intervaltimeend, Double lastspeed, Integer i) {
+    private static void newMethod(ProEconStateTranRatesSub2 sub2, Double interval1, Double interval2, Double interval3, List<Date> intervaltimebegin, List<Date> intervaltimeend) {
 
         if (interval1 >= interval2 && interval1 >= interval3) {
 
@@ -864,6 +872,7 @@ public class TimelinessRateService {
         if (subs.get(i).getSpeed() == 3.0) {
             interval1 += subs.get(i).getDurationHours();
 
+
             lastspeed = 3.0;
         } else if (subs.get(i).getSpeed() == 3.5) {
             interval2 += subs.get(i).getDurationHours();
@@ -892,28 +901,7 @@ public class TimelinessRateService {
         }
     }
 
-    public void buildresetRateByState(ProEconStateTransitionRates dayInfo, ProEconStateTransitionRates day) {
-        dayInfo.setRecordDate(day.getRecordDate());
-        dayInfo.setWindpwoerId(day.getWindpwoerId());
-        dayInfo.setProjectId(day.getProjectId());
-        dayInfo.setWindturbineId(day.getWindturbineId());
-        dayInfo.setLineId(day.getLineId());
-        dayInfo.setTimerate1(day.getTimerate1());
-        dayInfo.setTimerate2(day.getTimerate2());
-        dayInfo.setTimerate3(day.getTimerate3());
-        dayInfo.setTimerate4(day.getTimerate4());
-        dayInfo.setTimerate5(day.getTimerate5());
-        dayInfo.setTimerate6(day.getTimerate6());
-        dayInfo.setTimerate7(day.getTimerate7());
-        dayInfo.setTimerate8(day.getTimerate8());
-        dayInfo.setTimerate9(day.getTimerate9());
-        dayInfo.setTimerate10(day.getTimerate10());
-        dayInfo.setTimerate11(day.getTimerate11());
-        dayInfo.setTimerate12(day.getTimerate12());
-        dayInfo.setTimerate13(day.getTimerate13());
-        dayInfo.setTimerate14(day.getTimerate14());
-        dayInfo.setTimerate15(day.getTimerate15());
-    }
+
 
 
     private static void buildStatetransitionratesSub2(List<ProEconStateTranRatesSub> subs, ProEconStateTranRatesSub2 sub2, Integer i) {
@@ -1014,21 +1002,15 @@ public class TimelinessRateService {
         sub.setSpeed(speed);
     }
 
-    private double coefficient(List<PointVo> tmpeSpeed, double dbValue) {
-        double result = 0;
-        for (PointVo item : tmpeSpeed) {
-            result += (dbValue - item.getX()) / dbValue;
-        }
-        result = result / tmpeSpeed.size() * 100;
-        return result;
-    }
+
 
     //故障消缺及时率
 
     public void failRate(Date cuttentDate) {
 
-        Map<Date, Map<String, ProEconFaultLiminatedefects>> dtDictionary = new HashMap<Date, Map<String, ProEconFaultLiminatedefects>>();
+        Map<Date, Map<String, ProEconFaultLiminatedefects>> dtDictionary = new HashMap<>();
         Calendar c = Calendar.getInstance();
+        c.setTime(cuttentDate);
         //Date now = Date.Now.Date.AddMonths(-1); //上月
         Date now = DateUtils.truncate(c.getTime()); //本月
 
@@ -1062,7 +1044,7 @@ public class TimelinessRateService {
             if (dtDictionary.containsKey(dt)) {
                 fdDictionary = dtDictionary.get(dt);
             } else {
-                fdDictionary = new HashMap<String, ProEconFaultLiminatedefects>();
+                fdDictionary = new HashMap<>();
                 dtDictionary.put(dt, fdDictionary);
             }
             ProEconFaultLiminatedefects fs;
@@ -1075,6 +1057,9 @@ public class TimelinessRateService {
             } else {
                 fs = new ProEconFaultLiminatedefects();
                 fs.setWindturbineId(item.getWindturbineId());
+                fs.setRate(0.0);
+                fs.setRightCount(0.0);
+                fs.setFaultCount(0.0);
 
                 if (CacheContext.wtmap.containsKey(item.getWindturbineId())) {
                     ProBasicEquipment wt = CacheContext.wtmap.get(item.getWindturbineId());
@@ -1102,7 +1087,7 @@ public class TimelinessRateService {
 
             }
             if (fs.getFaultCount() != 0) {
-                double temp = new BigDecimal(fs.getRightCount()).divide(new BigDecimal(fs.getFaultCount()), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
+                double temp = BigDecimal.valueOf(fs.getRightCount()).divide(BigDecimal.valueOf(fs.getFaultCount()), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
 
                 fs.setRate(temp);
 

ファイルの差分が大きいため隠しています
+ 612 - 755
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo1Service.java


ファイルの差分が大きいため隠しています
+ 454 - 511
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo2Service.java


ファイルの差分が大きいため隠しています
+ 352 - 411
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo3Service.java


ファイルの差分が大きいため隠しています
+ 459 - 435
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo4Service.java


+ 254 - 296
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo5Service.java

@@ -19,7 +19,7 @@ import java.util.stream.Collectors;
 @Service
 public class WindPowerInfo5Service {
 
-//    private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
+    //    private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
     @Resource
     private IEdosUtil edosUtil;
 
@@ -27,69 +27,61 @@ public class WindPowerInfo5Service {
     private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
 
 
-
-
     /**
      * 计算区域日信息
      */
     public void calRegionInfoDay(Date recordDate) {
 
         List<ProEconPowerstationInfoDay5> wpinfodayls = proEconPowerstationInfoDay5Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                        && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.cp.getValue()))
                 .collect(Collectors.toList());
-        if(!wpinfodayls.isEmpty())
-        {
-
-            Map<String, Map<String, List<ProEconPowerstationInfoDay5>>>rgmap=new HashMap<>();
-
+        if (!wpinfodayls.isEmpty()) {
 
+            Map<String, Map<String, List<ProEconPowerstationInfoDay5>>> rgmap = new HashMap<>();
 
 
-            for(ProEconPowerstationInfoDay5 wpinfo:wpinfodayls)
-            {
+            for (ProEconPowerstationInfoDay5 wpinfo : wpinfodayls) {
 
-                if(rgmap.containsKey(wpinfo.getRegionId()))
-                {
-                    Map<String, List<ProEconPowerstationInfoDay5>> map=rgmap.get(wpinfo.getRegionId());
-                    List<ProEconPowerstationInfoDay5> qbls=map.get("qb");
-                    List<ProEconPowerstationInfoDay5> gfls=map.get("fd");
-                    List<ProEconPowerstationInfoDay5> fdls=map.get("gf");
+                if (rgmap.containsKey(wpinfo.getRegionId())) {
+                    Map<String, List<ProEconPowerstationInfoDay5>> map = rgmap.get(wpinfo.getRegionId());
+                    List<ProEconPowerstationInfoDay5> qbls = map.get("qb");
+                    List<ProEconPowerstationInfoDay5> fdls = map.get("fd");
+                    List<ProEconPowerstationInfoDay5> gfls = map.get("gf");
 
-                    if(wpinfo.getForeignKeyId().equals("-1"))
-                    {
+                    if (wpinfo.getForeignKeyId().equals("-1")) {
                         fdls.add(wpinfo);
-                    }else if(wpinfo.getForeignKeyId().equals("-2")){
+                    } else if (wpinfo.getForeignKeyId().equals("-2")) {
                         gfls.add(wpinfo);
+                    } else if (wpinfo.getForeignKeyId().equals("0")) {
+                        qbls.add(wpinfo);
                     }
-                    qbls.add(wpinfo);
-                }else
-                {
-                    Map<String, List<ProEconPowerstationInfoDay5>> map=new HashMap<>();
 
-                    List<ProEconPowerstationInfoDay5> qbls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay5> gfls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay5> fdls=new ArrayList<>();
+                } else {
+                    Map<String, List<ProEconPowerstationInfoDay5>> map = new HashMap<>();
+
+                    List<ProEconPowerstationInfoDay5> qbls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay5> fdls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay5> gfls =  new ArrayList<>();
 
-                    if(wpinfo.getForeignKeyId().equals("-1"))
-                    {
+                    if (wpinfo.getForeignKeyId().equals("-1")) {
                         fdls.add(wpinfo);
-                    }else if(wpinfo.getForeignKeyId().equals("-2")){
+                    } else if (wpinfo.getForeignKeyId().equals("-2")) {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                    map.put("qb",qbls);
-                    map.put("fd",fdls);
-                    map.put("gf",gfls);
-                    rgmap.put(wpinfo.getRegionId(),map);
+                    map.put("qb", qbls);
+                    map.put("fd", fdls);
+                    map.put("gf", gfls);
+                    rgmap.put(wpinfo.getRegionId(), map);
                 }
             }
 
 
             //判断是否有重复记录,先删除重复记录
             List<String> idls = proEconPowerstationInfoDay5Service.list().stream()
-                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                            && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                             && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay5::getId)
                     .collect(Collectors.toList());
@@ -99,21 +91,20 @@ public class WindPowerInfo5Service {
                 proEconPowerstationInfoDay5Service.removeByIds(idls);
 
             }
-            for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay5>>> entry:rgmap.entrySet()){
-                Map<String, List<ProEconPowerstationInfoDay5>> map=entry.getValue();
-                List<ProEconPowerstationInfoDay5> qbls=map.get("qb");
-                List<ProEconPowerstationInfoDay5> gfls=map.get("fd");
-                List<ProEconPowerstationInfoDay5> fdls=map.get("gf");
+            for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay5>>> entry : rgmap.entrySet()) {
+                Map<String, List<ProEconPowerstationInfoDay5>> map = entry.getValue();
+                List<ProEconPowerstationInfoDay5> qbls = map.get("qb");
+                List<ProEconPowerstationInfoDay5> fdls = map.get("fd");
+                List<ProEconPowerstationInfoDay5> gfls = map.get("gf");
 //                if(CacheContext.cpwpmap.size()==qbls.size())
 //                {
 
-                ProEconPowerstationInfoDay5 qb=new ProEconPowerstationInfoDay5();
-                ProEconPowerstationInfoDay5 fd=new ProEconPowerstationInfoDay5();
-                ProEconPowerstationInfoDay5 gf=new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 qb = new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 fd = new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 gf = new ProEconPowerstationInfoDay5();
 
-                if(CacheContext.rgmap.containsKey(entry.getKey()))
-                {
-                    ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey());
+                if (CacheContext.rgmap.containsKey(entry.getKey())) {
+                    ProBasicRegion cp = CacheContext.rgmap.get(entry.getKey());
                     gf.setRegionId(cp.getId());
 
                     gf.setRecordDate(DateUtils.truncate(recordDate));
@@ -132,12 +123,15 @@ public class WindPowerInfo5Service {
                     qb.setForeignKeyId("0");
                     qb.setLocation(Location.rg.getValue());
 
+                    Initial.initial(qb);
+                    Initial.initial(fd);
+                    Initial.initial(gf);
                     //计算区域级全部
-                    calCp(qb,qbls);
+                    calCp(qb, qbls);
                     //计算公司级风电场站
-                    calCp(fd,fdls);
+                    calCp(fd, fdls);
                     //计算公司级光电场站
-                    calCp(gf,gfls);
+                    calCp(gf, gfls);
 
                     proEconPowerstationInfoDay5Service.save(qb);
                     proEconPowerstationInfoDay5Service.save(fd);
@@ -152,9 +146,6 @@ public class WindPowerInfo5Service {
 //                }
 
 
-
-
-
             }
         }
 
@@ -166,61 +157,53 @@ public class WindPowerInfo5Service {
     public void calCompanyInfoDay(Date recordDate) {
 
         List<ProEconPowerstationInfoDay5> wpinfodayls = proEconPowerstationInfoDay5Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                        && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.wp.getValue()))
                 .collect(Collectors.toList());
-        if(!wpinfodayls.isEmpty())
-        {
-
-            Map<String, Map<String, List<ProEconPowerstationInfoDay5>>>cpmap=new HashMap<>();
-
+        if (!wpinfodayls.isEmpty()) {
 
+            Map<String, Map<String, List<ProEconPowerstationInfoDay5>>> cpmap = new HashMap<>();
 
 
-            for(ProEconPowerstationInfoDay5 wpinfo:wpinfodayls)
-            {
+            for (ProEconPowerstationInfoDay5 wpinfo : wpinfodayls) {
 
-                if(cpmap.containsKey(wpinfo.getCompanyId()))
-                {
-                    Map<String, List<ProEconPowerstationInfoDay5>> map=cpmap.get(wpinfo.getCompanyId());
-                    List<ProEconPowerstationInfoDay5> qbls=map.get("qb");
-                    List<ProEconPowerstationInfoDay5> gfls=map.get("fd");
-                    List<ProEconPowerstationInfoDay5> fdls=map.get("gf");
+                if (cpmap.containsKey(wpinfo.getCompanyId())) {
+                    Map<String, List<ProEconPowerstationInfoDay5>> map = cpmap.get(wpinfo.getCompanyId());
+                    List<ProEconPowerstationInfoDay5> qbls = map.get("qb");
+                    List<ProEconPowerstationInfoDay5> fdls = map.get("fd");
+                    List<ProEconPowerstationInfoDay5> gfls = map.get("gf");
 
-                    if(wpinfo.getWindpowerstationId().contains("FDC"))
-                    {
+                    if (wpinfo.getWindpowerstationId().contains("FDC")) {
                         fdls.add(wpinfo);
-                    }else {
+                    } else {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                }else
-                {
-                    Map<String, List<ProEconPowerstationInfoDay5>> map=new HashMap<>();
+                } else {
+                    Map<String, List<ProEconPowerstationInfoDay5>> map = new HashMap<>();
 
-                    List<ProEconPowerstationInfoDay5> qbls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay5> gfls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay5> fdls=new ArrayList<>();
+                    List<ProEconPowerstationInfoDay5> qbls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay5> gfls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay5> fdls = new ArrayList<>();
 
-                    if(wpinfo.getWindpowerstationId().contains("FDC"))
-                    {
+                    if (wpinfo.getWindpowerstationId().contains("FDC")) {
                         fdls.add(wpinfo);
-                    }else {
+                    } else {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                    map.put("qb",qbls);
-                    map.put("fd",fdls);
-                    map.put("gf",gfls);
-                    cpmap.put(wpinfo.getCompanyId(),map);
+                    map.put("qb", qbls);
+                    map.put("fd", fdls);
+                    map.put("gf", gfls);
+                    cpmap.put(wpinfo.getCompanyId(), map);
                 }
             }
 
 
             //判断是否有重复记录,先删除重复记录
             List<String> idls = proEconPowerstationInfoDay5Service.list().stream()
-                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                            && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                             && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay5::getId)
                     .collect(Collectors.toList());
@@ -230,21 +213,20 @@ public class WindPowerInfo5Service {
                 proEconPowerstationInfoDay5Service.removeByIds(idls);
 
             }
-            for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay5>>> entry:cpmap.entrySet()){
-                Map<String, List<ProEconPowerstationInfoDay5>> map=entry.getValue();
-                List<ProEconPowerstationInfoDay5> qbls=map.get("qb");
-                List<ProEconPowerstationInfoDay5> gfls=map.get("fd");
-                List<ProEconPowerstationInfoDay5> fdls=map.get("gf");
+            for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay5>>> entry : cpmap.entrySet()) {
+                Map<String, List<ProEconPowerstationInfoDay5>> map = entry.getValue();
+                List<ProEconPowerstationInfoDay5> qbls = map.get("qb");
+                List<ProEconPowerstationInfoDay5> fdls = map.get("fd");
+                List<ProEconPowerstationInfoDay5> gfls = map.get("gf");
 //                if(CacheContext.cpwpmap.size()==qbls.size())
 //                {
 
-                ProEconPowerstationInfoDay5 qb=new ProEconPowerstationInfoDay5();
-                ProEconPowerstationInfoDay5 fd=new ProEconPowerstationInfoDay5();
-                ProEconPowerstationInfoDay5 gf=new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 qb = new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 fd = new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 gf = new ProEconPowerstationInfoDay5();
 
-                if(CacheContext.cpmap.containsKey(entry.getKey()))
-                {
-                    ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey());
+                if (CacheContext.cpmap.containsKey(entry.getKey())) {
+                    ProBasicCompany cp = CacheContext.cpmap.get(entry.getKey());
                     gf.setRegionId(cp.getRegionId());
                     gf.setCompanyId(cp.getId());
                     gf.setRecordDate(DateUtils.truncate(recordDate));
@@ -252,7 +234,6 @@ public class WindPowerInfo5Service {
                     gf.setLocation(Location.cp.getValue());
 
 
-
                     fd.setRegionId(cp.getRegionId());
                     fd.setCompanyId(cp.getId());
                     fd.setRecordDate(DateUtils.truncate(recordDate));
@@ -265,12 +246,16 @@ public class WindPowerInfo5Service {
                     qb.setForeignKeyId("0");
                     qb.setLocation(Location.cp.getValue());
 
+                    Initial.initial(qb);
+                    Initial.initial(fd);
+                    Initial.initial(gf);
+
                     //计算公司级全部场站
-                    calCp(qb,qbls);
+                    calCp(qb, qbls);
                     //计算公司级风电场站
-                    calCp(fd,fdls);
+                    calCp(fd, fdls);
                     //计算公司级光电场站
-                    calCp(gf,gfls);
+                    calCp(gf, gfls);
 
                     proEconPowerstationInfoDay5Service.save(qb);
                     proEconPowerstationInfoDay5Service.save(fd);
@@ -285,71 +270,66 @@ public class WindPowerInfo5Service {
 //                }
 
 
-
-
-
             }
         }
 
     }
 
-    private void calCp(ProEconPowerstationInfoDay5 pewp,List<ProEconPowerstationInfoDay5> ls) {
+    private void calCp(ProEconPowerstationInfoDay5 pewp, List<ProEconPowerstationInfoDay5> ls) {
 
-        if(!ls.isEmpty())
-        {
+        if (!ls.isEmpty()) {
 
 
-
-            for(ProEconPowerstationInfoDay5 pepid:ls)
-            {
+            for (ProEconPowerstationInfoDay5 pepid : ls) {
                 //日发电量(升压站)
-                pewp.setRfdldb(StringUtils.round(pewp.getRfdldb()+pepid.getRfdldb(),2));
+                pewp.setRfdldb(StringUtils.round(pewp.getRfdldb() + pepid.getRfdldb(), 2));
                 //日上网电量
-                pewp.setRswdldb(StringUtils.round(pewp.getRswdldb()+pepid.getRswdldb(),2));
+                pewp.setRswdldb(StringUtils.round(pewp.getRswdldb() + pepid.getRswdldb(), 2));
                 //日工网购网电量
-                pewp.setRgwgwdldb(StringUtils.round(pewp.getRgwgwdldb()+pepid.getRgwgwdldb(),2));
+                pewp.setRgwgwdldb(StringUtils.round(pewp.getRgwgwdldb() + pepid.getRgwgwdldb(), 2));
                 //日农网购网电量
-                pewp.setRnwgwdldb(StringUtils.round(pewp.getRnwgwdldb()+pepid.getRnwgwdldb(),2));
+                pewp.setRnwgwdldb(StringUtils.round(pewp.getRnwgwdldb() + pepid.getRnwgwdldb(), 2));
                 //日综合场用电量(电表)
-                pewp.setRzhcydldb(StringUtils.round(pewp.getRzhcydldb()+pepid.getRzhcydldb(),2));
+                pewp.setRzhcydldb(StringUtils.round(pewp.getRzhcydldb() + pepid.getRzhcydldb(), 2));
                 //日厂用电量
-                pewp.setRfdcydldb(StringUtils.round(pewp.getRfdcydldb()+pepid.getRfdcydldb(),2));
+                pewp.setRfdcydldb(StringUtils.round(pewp.getRfdcydldb() + pepid.getRfdcydldb(), 2));
 
                 //月发电量(升压站)
-                pewp.setYfdldb(StringUtils.round(pewp.getYfdldb()+pepid.getYfdldb(),2));
+                pewp.setYfdldb(StringUtils.round(pewp.getYfdldb() + pepid.getYfdldb(), 2));
                 //月上网电量
-                pewp.setYswdldb(StringUtils.round(pewp.getYswdldb()+pepid.getYswdldb(),2));
+                pewp.setYswdldb(StringUtils.round(pewp.getYswdldb() + pepid.getYswdldb(), 2));
                 //月工网购网电量
-                pewp.setYgwgwdldb(StringUtils.round(pewp.getYgwgwdldb()+pepid.getYgwgwdldb(),2));
+                pewp.setYgwgwdldb(StringUtils.round(pewp.getYgwgwdldb() + pepid.getYgwgwdldb(), 2));
                 //月农网购网电量
-                pewp.setYnwgwdldb(StringUtils.round(pewp.getYnwgwdldb()+pepid.getYnwgwdldb(),2));
+                pewp.setYnwgwdldb(StringUtils.round(pewp.getYnwgwdldb() + pepid.getYnwgwdldb(), 2));
                 //月综合场用电量(电表)
-                pewp.setYzhcydldb(StringUtils.round(pewp.getYzhcydldb()+pepid.getYzhcydldb(),2));
+                pewp.setYzhcydldb(StringUtils.round(pewp.getYzhcydldb() + pepid.getYzhcydldb(), 2));
                 //月厂用电量
-                pewp.setYfdcydldb(StringUtils.round(pewp.getYfdcydldb()+pepid.getYfdcydldb(),2));
+                pewp.setYfdcydldb(StringUtils.round(pewp.getYfdcydldb() + pepid.getYfdcydldb(), 2));
 
                 //年发电量(升压站)
-                pewp.setNfdldb(StringUtils.round(pewp.getNfdldb()+pepid.getNfdldb(),2));
+                pewp.setNfdldb(StringUtils.round(pewp.getNfdldb() + pepid.getNfdldb(), 2));
                 //年上网电量
-                pewp.setNswdldb(StringUtils.round(pewp.getNswdldb()+pepid.getNswdldb(),2));
+                pewp.setNswdldb(StringUtils.round(pewp.getNswdldb() + pepid.getNswdldb(), 2));
                 //年工网购网电量
-                pewp.setNgwgwdldb(StringUtils.round(pewp.getNgwgwdldb()+pepid.getNgwgwdldb(),2));
+                pewp.setNgwgwdldb(StringUtils.round(pewp.getNgwgwdldb() + pepid.getNgwgwdldb(), 2));
                 //年农网购网电量
-                pewp.setNnwgwdldb(StringUtils.round(pewp.getNnwgwdldb()+pepid.getNnwgwdldb(),2));
+                pewp.setNnwgwdldb(StringUtils.round(pewp.getNnwgwdldb() + pepid.getNnwgwdldb(), 2));
                 //年综合场用电量(电表)
-                pewp.setNzhcydldb(StringUtils.round(pewp.getNzhcydldb()+pepid.getNzhcydldb(),2));
+                pewp.setNzhcydldb(StringUtils.round(pewp.getNzhcydldb() + pepid.getNzhcydldb(), 2));
                 //年厂用电量
-                pewp.setNfdcydldb(StringUtils.round(pewp.getNfdcydldb()+pepid.getNfdcydldb(),2));
+                pewp.setNfdcydldb(StringUtils.round(pewp.getNfdcydldb() + pepid.getNfdcydldb(), 2));
 
             }
 
         }
     }
+
     /**
      * 计算场站日信息
      */
     public void calWindpowerInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
 //        Date end=c.getTime();
@@ -362,7 +342,7 @@ public class WindPowerInfo5Service {
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay5Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay5::getId)
                 .collect(Collectors.toList());
@@ -372,13 +352,11 @@ public class WindPowerInfo5Service {
             proEconPowerstationInfoDay5Service.removeByIds(idls);
 
         }
-        for(ProBasicPowerstation wp:CacheContext.wpls)
-        {
-            if(CacheContext.wppointmap.containsKey(wp.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(wp.getId());
+        for (ProBasicPowerstation wp : CacheContext.wpls) {
+            if (CacheContext.wppointmap.containsKey(wp.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.wppointmap.get(wp.getId());
 
-                ProEconPowerstationInfoDay5 pewp=new ProEconPowerstationInfoDay5();
+                ProEconPowerstationInfoDay5 pewp = new ProEconPowerstationInfoDay5();
                 Initial.initial(pewp);
                 pewp.setRegionId(wp.getRegionId());
                 pewp.setCompanyId(wp.getCompanyId());
@@ -400,7 +378,7 @@ public class WindPowerInfo5Service {
 //                                    && i.getLocation().equals(Location.wp.getValue()))
 //                            .collect(Collectors.toList());
 //                }
-                extracted(recordDate,  pointmap, pewp);
+                extracted(recordDate, pointmap, pewp);
 //*******************************************年信息统计*********************************************************/
 //                wpinfodayls.add(pewp);
                 proEconPowerstationInfoDay5Service.save(pewp);
@@ -416,7 +394,7 @@ public class WindPowerInfo5Service {
      * 计算项目日信息
      */
     public void calProjectInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
 //        Date end=c.getTime();
@@ -425,7 +403,7 @@ public class WindPowerInfo5Service {
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay5Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.pjmap.containsKey(i.getProjectId())
                         && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay5::getId)
                 .collect(Collectors.toList());
@@ -435,13 +413,16 @@ public class WindPowerInfo5Service {
             proEconPowerstationInfoDay5Service.removeByIds(idls);
 
         }
-        for(ProBasicProject pj:CacheContext.pjls)
-        {
-            if(CacheContext.wppointmap.containsKey(pj.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(pj.getId());
-
-                ProEconPowerstationInfoDay5 pewp=new ProEconPowerstationInfoDay5();
+        for (ProBasicProject pj : CacheContext.pjls) {
+            if (CacheContext.propointmap.containsKey(pj.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.propointmap.get(pj.getId());
+
+                ProEconPowerstationInfoDay5 pewp = new ProEconPowerstationInfoDay5();
+                if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
+                    ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
+                    pewp.setRegionId(wp.getRegionId());
+                    pewp.setCompanyId(wp.getCompanyId());
+                }
                 Initial.initial(pewp);
                 pewp.setForeignKeyId("0");
                 pewp.setWindpowerstationId(pj.getWindpowerstationId());
@@ -473,11 +454,12 @@ public class WindPowerInfo5Service {
         }
 
     }
+
     /**
      * 计算线路日信息
      */
     public void calLineInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
 //        Date end=c.getTime();
@@ -486,9 +468,9 @@ public class WindPowerInfo5Service {
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay5Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.lnmap.containsKey(i.getLineId())
-                        && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay5::getId)
+                        && i.getLocation().equals(Location.ln.getValue())).map(ProEconPowerstationInfoDay5::getId)
                 .collect(Collectors.toList());
 
         if (idls.size() > 0) {
@@ -496,13 +478,21 @@ public class WindPowerInfo5Service {
             proEconPowerstationInfoDay5Service.removeByIds(idls);
 
         }
-        for(ProBasicLine ln:CacheContext.lnls)
-        {
-            if(CacheContext.wppointmap.containsKey(ln.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(ln.getId());
+        for (ProBasicLine ln : CacheContext.lnls) {
+            if (CacheContext.linepointmap.containsKey(ln.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.linepointmap.get(ln.getId());
+
+                ProEconPowerstationInfoDay5 pewp = new ProEconPowerstationInfoDay5();
+                if (CacheContext.pjmap.containsKey(ln.getProjectId())) {
+                    ProBasicProject pj = CacheContext.pjmap.get(ln.getProjectId());
+                    if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
+                        ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
+                        pewp.setRegionId(wp.getRegionId());
+                        pewp.setCompanyId(wp.getCompanyId());
+                        pewp.setWindpowerstationId(wp.getId());
+                    }
 
-                ProEconPowerstationInfoDay5 pewp=new ProEconPowerstationInfoDay5();
+                }
                 Initial.initial(pewp);
                 pewp.setForeignKeyId("0");
                 pewp.setLineId(ln.getId());
@@ -523,7 +513,7 @@ public class WindPowerInfo5Service {
 //                                    && i.getLocation().equals(Location.ln.getValue()))
 //                            .collect(Collectors.toList());
 //                }
-                extracted(recordDate,  pointmap, pewp);
+                extracted(recordDate, pointmap, pewp);
 
                 proEconPowerstationInfoDay5Service.save(pewp);
 
@@ -534,154 +524,134 @@ public class WindPowerInfo5Service {
 
     }
 
-    private void extracted(Date recordDate,  Map<String, ProBasicPowerstationPoint> pointmap, ProEconPowerstationInfoDay5 pewp) throws Exception {
+    private void extracted(Date recordDate, Map<String, ProBasicPowerstationPoint> pointmap, ProEconPowerstationInfoDay5 pewp) throws Exception {
         //*******************************************日信息统计*********************************************************/
 
-                double rfdlsyz=0.0;
-                double rswdlsyz=0.0;
-                double rgwgwdlsyz=0.0;
-                double rnwgwdlsyz=0.0;
-                if(pointmap.containsKey(ContantXk.RFDLSYZ))
-                {
-                    ProBasicPowerstationPoint point=pointmap.get(ContantXk.RFDLSYZ);
-                    PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-                    if(StringUtils.notEmp(pointValue))
-                    {
-                        //日发电量(升压站)
-                        rfdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
-                        pewp.setRfdldb(rfdlsyz);
+        double rfdlsyz = 0.0;
+        double rswdlsyz = 0.0;
+        double rgwgwdlsyz = 0.0;
+        double rnwgwdlsyz = 0.0;
+        if (pointmap.containsKey(ContantXk.RFDLSYZ)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.RFDLSYZ);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
+                //日发电量(升压站)
+                rfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setRfdldb(rfdlsyz);
 
-                    }
-                }
+            }
+        }
 
-                if(pointmap.containsKey(ContantXk.RSWDL))
-                {
-                    ProBasicPowerstationPoint point=pointmap.get(ContantXk.RSWDL);
-                    PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-                    if(StringUtils.notEmp(pointValue))
-                    {
-                        //日上网电量
-                        rswdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
-                        pewp.setRswdldb(rswdlsyz);
+        if (pointmap.containsKey(ContantXk.RSWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.RSWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
+                //日上网电量
+                rswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setRswdldb(rswdlsyz);
 
-                    }
-                }
+            }
+        }
 
-                if(pointmap.containsKey(ContantXk.RGWGWDL))
-                {
-                    ProBasicPowerstationPoint point=pointmap.get(ContantXk.RGWGWDL);
-                    PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-                    if(StringUtils.notEmp(pointValue))
-                    {
-                        //日工网购网电量
-                        rgwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
-                        pewp.setRgwgwdldb(rgwgwdlsyz);
+        if (pointmap.containsKey(ContantXk.RGWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.RGWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
+                //日工网购网电量
+                rgwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setRgwgwdldb(rgwgwdlsyz);
 
-                    }
-                }
+            }
+        }
 
-                if(pointmap.containsKey(ContantXk.RNWGWDL))
-                {
-                    ProBasicPowerstationPoint point=pointmap.get(ContantXk.RNWGWDL);
-                    PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-                    if(StringUtils.notEmp(pointValue))
-                    {
-                        //日农网购网电量
-                        rnwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
-                        pewp.setRnwgwdldb(rnwgwdlsyz);
+        if (pointmap.containsKey(ContantXk.RNWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.RNWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
+                //日农网购网电量
+                rnwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
+                pewp.setRnwgwdldb(rnwgwdlsyz);
 
-                    }
-                }
+            }
+        }
 
-                //日综合场用电量(电表)
-                pewp.setRzhcydldb(StringUtils.round(rfdlsyz-rswdlsyz+rgwgwdlsyz+rnwgwdlsyz,2));
+        //日综合场用电量(电表)
+        pewp.setRzhcydldb(StringUtils.round(rfdlsyz - rswdlsyz + rgwgwdlsyz + rnwgwdlsyz, 2));
 
 
-                if(pointmap.containsKey(ContantXk.RCYDL))
-                {
-                    ProBasicPowerstationPoint point=pointmap.get(ContantXk.RCYDL);
-                    PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-                    if(StringUtils.notEmp(pointValue))
-                    {
-                        //日厂用电量
-                        pewp.setRfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(),2));
+        if (pointmap.containsKey(ContantXk.RCYDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.RCYDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
+                //日厂用电量
+                pewp.setRfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
 
-                    }
-                }
+            }
+        }
 
 
 //*******************************************日信息统计*********************************************************/
 
 //*******************************************月信息统计*********************************************************/
 
-        double yfdlsyz=0.0;
-        double yswdlsyz=0.0;
-        double ygwgwdlsyz=0.0;
-        double ynwgwdlsyz=0.0;
-        if(pointmap.containsKey(ContantXk.YFDLSYZ))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.YFDLSYZ);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        double yfdlsyz = 0.0;
+        double yswdlsyz = 0.0;
+        double ygwgwdlsyz = 0.0;
+        double ynwgwdlsyz = 0.0;
+        if (pointmap.containsKey(ContantXk.YFDLSYZ)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.YFDLSYZ);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //月发电量(升压站)
-                yfdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                yfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYfdldb(yfdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.YSWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.YSWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.YSWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.YSWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //月上网电量
-                yswdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                yswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYswdldb(yswdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.YGWGWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.YGWGWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.YGWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.YGWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //月工网购网电量
-                ygwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                ygwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYgwgwdldb(ygwgwdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.YNWGWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.YNWGWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.YNWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.YNWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //月农网购网电量
-                ynwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                ynwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setYnwgwdldb(ynwgwdlsyz);
 
             }
         }
 
         //月综合场用电量(电表)
-        pewp.setYzhcydldb(StringUtils.round(yfdlsyz-yswdlsyz+ygwgwdlsyz+ynwgwdlsyz,2));
+        pewp.setYzhcydldb(StringUtils.round(yfdlsyz - yswdlsyz + ygwgwdlsyz + ynwgwdlsyz, 2));
 
 
-        if(pointmap.containsKey(ContantXk.YCYDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.YCYDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.YCYDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.YCYDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //月厂用电量
-                pewp.setYfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(),2));
+                pewp.setYfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
 
             }
         }
@@ -690,82 +660,70 @@ public class WindPowerInfo5Service {
 //*******************************************月信息统计*********************************************************/
 
 //*******************************************年信息统计*********************************************************/
-        double nfdlsyz=0.0;
-        double nswdlsyz=0.0;
-        double ngwgwdlsyz=0.0;
-        double nnwgwdlsyz=0.0;
-        if(pointmap.containsKey(ContantXk.NFDLSYZ))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.NFDLSYZ);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        double nfdlsyz = 0.0;
+        double nswdlsyz = 0.0;
+        double ngwgwdlsyz = 0.0;
+        double nnwgwdlsyz = 0.0;
+        if (pointmap.containsKey(ContantXk.NFDLSYZ)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.NFDLSYZ);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //年发电量(升压站)
-                nfdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                nfdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNfdldb(nfdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.NSWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.NSWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.NSWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.NSWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //年上网电量
-                nswdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                nswdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNswdldb(nswdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.NGWGWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.NGWGWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.NGWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.NGWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //年工网购网电量
-                ngwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                ngwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNgwgwdldb(ngwgwdlsyz);
 
             }
         }
 
-        if(pointmap.containsKey(ContantXk.NNWGWDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.NNWGWDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.NNWGWDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.NNWGWDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //年农网购网电量
-                nnwgwdlsyz=StringUtils.round(pointValue.getPointValueInDouble(),2);
+                nnwgwdlsyz = StringUtils.round(pointValue.getPointValueInDouble(), 2);
                 pewp.setNnwgwdldb(nnwgwdlsyz);
 
             }
         }
 
         //年综合场用电量(电表)
-        pewp.setNzhcydldb(StringUtils.round(nfdlsyz-nswdlsyz+ngwgwdlsyz+nnwgwdlsyz,2));
+        pewp.setNzhcydldb(StringUtils.round(nfdlsyz - nswdlsyz + ngwgwdlsyz + nnwgwdlsyz, 2));
 
 
-        if(pointmap.containsKey(ContantXk.NCYDL))
-        {
-            ProBasicPowerstationPoint point=pointmap.get(ContantXk.NCYDL);
-            PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(),recordDate.getTime()/1000);
-            if(StringUtils.notEmp(pointValue))
-            {
+        if (pointmap.containsKey(ContantXk.NCYDL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.NCYDL);
+            PointData pointValue = edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime() / 1000);
+            if (StringUtils.notEmp(pointValue)) {
                 //年厂用电量
-                pewp.setNfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(),2));
+                pewp.setNfdcydldb(StringUtils.round(pointValue.getPointValueInDouble(), 2));
 
             }
         }
     }
 
 
-
-
 }
 
 

+ 225 - 257
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindPowerInfo6Service.java

@@ -22,7 +22,7 @@ import java.util.stream.Collectors;
 @Service
 public class WindPowerInfo6Service {
 
-//    private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
+    //    private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
     @Resource
     private IEdosUtil edosUtil;
 
@@ -39,61 +39,55 @@ public class WindPowerInfo6Service {
     public void calRegionInfoDay(Date recordDate) {
 
         List<ProEconPowerstationInfoDay6> wpinfodayls = proEconPowerstationInfoDay6Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                        && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.cp.getValue()))
                 .collect(Collectors.toList());
-        if(!wpinfodayls.isEmpty())
-        {
+        if (!wpinfodayls.isEmpty()) {
 
-            Map<String, Map<String, List<ProEconPowerstationInfoDay6>>>rgmap=new HashMap<>();
+            Map<String, Map<String, List<ProEconPowerstationInfoDay6>>> rgmap = new HashMap<>();
 
 
+            for (ProEconPowerstationInfoDay6 wpinfo : wpinfodayls) {
 
+                if (rgmap.containsKey(wpinfo.getRegionId())) {
+                    Map<String, List<ProEconPowerstationInfoDay6>> map = rgmap.get(wpinfo.getRegionId());
+                    List<ProEconPowerstationInfoDay6> qbls = map.get("qb");
+                    List<ProEconPowerstationInfoDay6> fdls = map.get("fd");
+                    List<ProEconPowerstationInfoDay6> gfls = map.get("gf");
 
-            for(ProEconPowerstationInfoDay6 wpinfo:wpinfodayls)
-            {
-
-                if(rgmap.containsKey(wpinfo.getRegionId()))
-                {
-                    Map<String, List<ProEconPowerstationInfoDay6>> map=rgmap.get(wpinfo.getRegionId());
-                    List<ProEconPowerstationInfoDay6> qbls=map.get("qb");
-                    List<ProEconPowerstationInfoDay6> gfls=map.get("fd");
-                    List<ProEconPowerstationInfoDay6> fdls=map.get("gf");
-
-                    if(wpinfo.getForeignKeyId().equals("-1"))
-                    {
+                    if (wpinfo.getForeignKeyId().equals("-1")) {
                         fdls.add(wpinfo);
-                    }else if(wpinfo.getForeignKeyId().equals("-2")){
+                    } else if (wpinfo.getForeignKeyId().equals("-2")) {
                         gfls.add(wpinfo);
+                    } else if (wpinfo.getForeignKeyId().equals("0")) {
+                        qbls.add(wpinfo);
                     }
-                    qbls.add(wpinfo);
-                }else
-                {
-                    Map<String, List<ProEconPowerstationInfoDay6>> map=new HashMap<>();
 
-                    List<ProEconPowerstationInfoDay6> qbls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay6> gfls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay6> fdls=new ArrayList<>();
+                } else {
+                    Map<String, List<ProEconPowerstationInfoDay6>> map = new HashMap<>();
 
-                    if(wpinfo.getForeignKeyId().equals("-1"))
-                    {
+                    List<ProEconPowerstationInfoDay6> qbls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay6> gfls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay6> fdls = new ArrayList<>();
+
+                    if (wpinfo.getForeignKeyId().equals("-1")) {
                         fdls.add(wpinfo);
-                    }else if(wpinfo.getForeignKeyId().equals("-2")){
+                    } else if (wpinfo.getForeignKeyId().equals("-2")) {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                    map.put("qb",qbls);
-                    map.put("fd",fdls);
-                    map.put("gf",gfls);
-                    rgmap.put(wpinfo.getRegionId(),map);
+                    map.put("qb", qbls);
+                    map.put("fd", fdls);
+                    map.put("gf", gfls);
+                    rgmap.put(wpinfo.getRegionId(), map);
                 }
             }
 
 
             //判断是否有重复记录,先删除重复记录
             List<String> idls = proEconPowerstationInfoDay6Service.list().stream()
-                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                            && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                             && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay6::getId)
                     .collect(Collectors.toList());
@@ -103,21 +97,20 @@ public class WindPowerInfo6Service {
                 proEconPowerstationInfoDay6Service.removeByIds(idls);
 
             }
-            for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay6>>> entry:rgmap.entrySet()){
-                Map<String, List<ProEconPowerstationInfoDay6>> map=entry.getValue();
-                List<ProEconPowerstationInfoDay6> qbls=map.get("qb");
-                List<ProEconPowerstationInfoDay6> gfls=map.get("fd");
-                List<ProEconPowerstationInfoDay6> fdls=map.get("gf");
+            for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay6>>> entry : rgmap.entrySet()) {
+                Map<String, List<ProEconPowerstationInfoDay6>> map = entry.getValue();
+                List<ProEconPowerstationInfoDay6> qbls = map.get("qb");
+                List<ProEconPowerstationInfoDay6> fdls = map.get("fd");
+                List<ProEconPowerstationInfoDay6> gfls = map.get("gf");
 //                if(CacheContext.cpwpmap.size()==qbls.size())
 //                {
 
-                ProEconPowerstationInfoDay6 qb=new ProEconPowerstationInfoDay6();
-                ProEconPowerstationInfoDay6 fd=new ProEconPowerstationInfoDay6();
-                ProEconPowerstationInfoDay6 gf=new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 qb = new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 fd = new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 gf = new ProEconPowerstationInfoDay6();
 
-                if(CacheContext.rgmap.containsKey(entry.getKey()))
-                {
-                    ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey());
+                if (CacheContext.rgmap.containsKey(entry.getKey())) {
+                    ProBasicRegion cp = CacheContext.rgmap.get(entry.getKey());
                     gf.setRegionId(cp.getId());
 
                     gf.setRecordDate(DateUtils.truncate(recordDate));
@@ -136,12 +129,15 @@ public class WindPowerInfo6Service {
                     qb.setForeignKeyId("0");
                     qb.setLocation(Location.rg.getValue());
 
+                    Initial.initial(qb);
+                    Initial.initial(fd);
+                    Initial.initial(gf);
                     //计算区域级全部
-                    calCp(qb,qbls);
+                    calCp(qb, qbls);
                     //计算公司级风电场站
-                    calCp(fd,fdls);
+                    calCp(fd, fdls);
                     //计算公司级光电场站
-                    calCp(gf,gfls);
+                    calCp(gf, gfls);
 
                     proEconPowerstationInfoDay6Service.save(qb);
                     proEconPowerstationInfoDay6Service.save(fd);
@@ -156,9 +152,6 @@ public class WindPowerInfo6Service {
 //                }
 
 
-
-
-
             }
         }
 
@@ -170,61 +163,53 @@ public class WindPowerInfo6Service {
     public void calCompanyInfoDay(Date recordDate) {
 
         List<ProEconPowerstationInfoDay6> wpinfodayls = proEconPowerstationInfoDay6Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                        && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.wp.getValue()))
                 .collect(Collectors.toList());
-        if(!wpinfodayls.isEmpty())
-        {
-
-            Map<String, Map<String, List<ProEconPowerstationInfoDay6>>>cpmap=new HashMap<>();
+        if (!wpinfodayls.isEmpty()) {
 
+            Map<String, Map<String, List<ProEconPowerstationInfoDay6>>> cpmap = new HashMap<>();
 
 
+            for (ProEconPowerstationInfoDay6 wpinfo : wpinfodayls) {
 
-            for(ProEconPowerstationInfoDay6 wpinfo:wpinfodayls)
-            {
+                if (cpmap.containsKey(wpinfo.getCompanyId())) {
+                    Map<String, List<ProEconPowerstationInfoDay6>> map = cpmap.get(wpinfo.getCompanyId());
+                    List<ProEconPowerstationInfoDay6> qbls = map.get("qb");
+                    List<ProEconPowerstationInfoDay6> fdls = map.get("fd");
+                    List<ProEconPowerstationInfoDay6> gfls = map.get("gf");
 
-                if(cpmap.containsKey(wpinfo.getCompanyId()))
-                {
-                    Map<String, List<ProEconPowerstationInfoDay6>> map=cpmap.get(wpinfo.getCompanyId());
-                    List<ProEconPowerstationInfoDay6> qbls=map.get("qb");
-                    List<ProEconPowerstationInfoDay6> gfls=map.get("fd");
-                    List<ProEconPowerstationInfoDay6> fdls=map.get("gf");
-
-                    if(wpinfo.getWindpowerstationId().contains("FDC"))
-                    {
+                    if (wpinfo.getWindpowerstationId().contains("FDC")) {
                         fdls.add(wpinfo);
-                    }else {
+                    } else {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                }else
-                {
-                    Map<String, List<ProEconPowerstationInfoDay6>> map=new HashMap<>();
+                } else {
+                    Map<String, List<ProEconPowerstationInfoDay6>> map = new HashMap<>();
 
-                    List<ProEconPowerstationInfoDay6> qbls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay6> gfls=new ArrayList<>();
-                    List<ProEconPowerstationInfoDay6> fdls=new ArrayList<>();
+                    List<ProEconPowerstationInfoDay6> qbls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay6> gfls = new ArrayList<>();
+                    List<ProEconPowerstationInfoDay6> fdls = new ArrayList<>();
 
-                    if(wpinfo.getWindpowerstationId().contains("FDC"))
-                    {
+                    if (wpinfo.getWindpowerstationId().contains("FDC")) {
                         fdls.add(wpinfo);
-                    }else {
+                    } else {
                         gfls.add(wpinfo);
                     }
                     qbls.add(wpinfo);
-                    map.put("qb",qbls);
-                    map.put("fd",fdls);
-                    map.put("gf",gfls);
-                    cpmap.put(wpinfo.getCompanyId(),map);
+                    map.put("qb", qbls);
+                    map.put("fd", fdls);
+                    map.put("gf", gfls);
+                    cpmap.put(wpinfo.getCompanyId(), map);
                 }
             }
 
 
             //判断是否有重复记录,先删除重复记录
             List<String> idls = proEconPowerstationInfoDay6Service.list().stream()
-                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                    .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
 //                            && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                             && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay6::getId)
                     .collect(Collectors.toList());
@@ -234,21 +219,20 @@ public class WindPowerInfo6Service {
                 proEconPowerstationInfoDay6Service.removeByIds(idls);
 
             }
-            for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay6>>> entry:cpmap.entrySet()){
-                Map<String, List<ProEconPowerstationInfoDay6>> map=entry.getValue();
-                List<ProEconPowerstationInfoDay6> qbls=map.get("qb");
-                List<ProEconPowerstationInfoDay6> gfls=map.get("fd");
-                List<ProEconPowerstationInfoDay6> fdls=map.get("gf");
+            for (Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay6>>> entry : cpmap.entrySet()) {
+                Map<String, List<ProEconPowerstationInfoDay6>> map = entry.getValue();
+                List<ProEconPowerstationInfoDay6> qbls = map.get("qb");
+                List<ProEconPowerstationInfoDay6> fdls = map.get("fd");
+                List<ProEconPowerstationInfoDay6> gfls = map.get("gf");
 //                if(CacheContext.cpwpmap.size()==qbls.size())
 //                {
 
-                ProEconPowerstationInfoDay6 qb=new ProEconPowerstationInfoDay6();
-                ProEconPowerstationInfoDay6 fd=new ProEconPowerstationInfoDay6();
-                ProEconPowerstationInfoDay6 gf=new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 qb = new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 fd = new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 gf = new ProEconPowerstationInfoDay6();
 
-                if(CacheContext.cpmap.containsKey(entry.getKey()))
-                {
-                    ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey());
+                if (CacheContext.cpmap.containsKey(entry.getKey())) {
+                    ProBasicCompany cp = CacheContext.cpmap.get(entry.getKey());
                     gf.setRegionId(cp.getRegionId());
                     gf.setCompanyId(cp.getId());
                     gf.setRecordDate(DateUtils.truncate(recordDate));
@@ -256,7 +240,6 @@ public class WindPowerInfo6Service {
                     gf.setLocation(Location.cp.getValue());
 
 
-
                     fd.setRegionId(cp.getRegionId());
                     fd.setCompanyId(cp.getId());
                     fd.setRecordDate(DateUtils.truncate(recordDate));
@@ -269,12 +252,15 @@ public class WindPowerInfo6Service {
                     qb.setForeignKeyId("0");
                     qb.setLocation(Location.cp.getValue());
 
+                    Initial.initial(qb);
+                    Initial.initial(fd);
+                    Initial.initial(gf);
                     //计算公司级全部场站
-                    calCp(qb,qbls);
+                    calCp(qb, qbls);
                     //计算公司级风电场站
-                    calCp(fd,fdls);
+                    calCp(fd, fdls);
                     //计算公司级光电场站
-                    calCp(gf,gfls);
+                    calCp(gf, gfls);
 
                     proEconPowerstationInfoDay6Service.save(qb);
                     proEconPowerstationInfoDay6Service.save(fd);
@@ -289,107 +275,104 @@ public class WindPowerInfo6Service {
 //                }
 
 
-
-
-
             }
         }
 
     }
 
-    private void calCp(ProEconPowerstationInfoDay6 pewp,List<ProEconPowerstationInfoDay6> ls) {
+    private void calCp(ProEconPowerstationInfoDay6 pewp, List<ProEconPowerstationInfoDay6> ls) {
 
-        if(!ls.isEmpty())
-        {
+        if (!ls.isEmpty()) {
             //日发电量
 //            DoubleSummaryStatistics summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay1::getRfdl).summaryStatistics();
 //            pewp.setRfdl(com.gyee.common.model.StringUtils.round(summaryStatistics.getSum(),2));
 
-            
-             //* 日最大风速(测风塔)
-            DoubleSummaryStatistics summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzdfscft).summaryStatistics();
-            pewp.setRzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+
+            //* 日最大风速(测风塔)
+            DoubleSummaryStatistics summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzdfscft).summaryStatistics();
+            pewp.setRzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 日最小风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzxfscft).summaryStatistics();
-            pewp.setRzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
-            
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzxfscft).summaryStatistics();
+            pewp.setRzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
+
             // * 日最大功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzdglcx).summaryStatistics();
-            pewp.setRzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzdglcx).summaryStatistics();
+            pewp.setRzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 日最小功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzxglcx).summaryStatistics();
-            pewp.setRzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRzxglcx).summaryStatistics();
+            pewp.setRzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
 
             // * 日平均功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRpjglcx).summaryStatistics();
-            pewp.setRpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRpjglcx).summaryStatistics();
+            pewp.setRpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
             // * 日平均风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRpjfscft).summaryStatistics();
-            pewp.setRpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getRpjfscft).summaryStatistics();
+            pewp.setRpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
             // * 月最大风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzdfscft).summaryStatistics();
-            pewp.setYzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzdfscft).summaryStatistics();
+            pewp.setYzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 月最小风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzxfscft).summaryStatistics();
-            pewp.setYzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzxfscft).summaryStatistics();
+            pewp.setYzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
 
             // * 月最大功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzdglcx).summaryStatistics();
-            pewp.setYzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzdglcx).summaryStatistics();
+            pewp.setYzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 月最小功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzxglcx).summaryStatistics();
-            pewp.setYzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYzxglcx).summaryStatistics();
+            pewp.setYzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
 
-           //  * 月平均功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYpjglcx).summaryStatistics();
-            pewp.setYpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            //  * 月平均功率(出线)
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYpjglcx).summaryStatistics();
+            pewp.setYpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
             // * 月平均风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYpjfscft).summaryStatistics();
-            pewp.setYpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getYpjfscft).summaryStatistics();
+            pewp.setYpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
             // * 年最大风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzdfscft).summaryStatistics();
-            pewp.setNzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzdfscft).summaryStatistics();
+            pewp.setNzdfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 年最小风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzxfscft).summaryStatistics();
-            pewp.setNzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzxfscft).summaryStatistics();
+            pewp.setNzxfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
 
             // * 年最大功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzdglcx).summaryStatistics();
-            pewp.setNzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzdglcx).summaryStatistics();
+            pewp.setNzdglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMax(), 2));
 
             // * 年最小功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzxglcx).summaryStatistics();
-            pewp.setNzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNzxglcx).summaryStatistics();
+            pewp.setNzxglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getMin(), 2));
 
             // * 年平均功率(出线)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNpjglcx).summaryStatistics();
-            pewp.setNpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNpjglcx).summaryStatistics();
+            pewp.setNpjglcx(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
             // * 年平均风速(测风塔)
-            summaryStatistics=ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNpjfscft).summaryStatistics();
-            pewp.setNpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(),2));
+            summaryStatistics = ls.stream().mapToDouble(ProEconPowerstationInfoDay6::getNpjfscft).summaryStatistics();
+            pewp.setNpjfscft(com.gyee.common.model.StringUtils.round(summaryStatistics.getAverage(), 2));
 
         }
     }
+
     /**
      * 计算场站日信息
      */
     public void calWindpowerInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
-        Date end=c.getTime();
+        Date end = c.getTime();
 
-        Date begin= DateUtils.truncate(c.getTime());
+        Date begin = DateUtils.truncate(c.getTime());
 
 
 //        List<ProEconPowerstationInfoDay6> wpinfodayls=new ArrayList<>();
@@ -397,7 +380,7 @@ public class WindPowerInfo6Service {
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay6Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
                         && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay6::getId)
                 .collect(Collectors.toList());
@@ -407,13 +390,11 @@ public class WindPowerInfo6Service {
             proEconPowerstationInfoDay6Service.removeByIds(idls);
 
         }
-        for(ProBasicPowerstation wp:CacheContext.wpls)
-        {
-            if(CacheContext.wppointmap.containsKey(wp.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(wp.getId());
+        for (ProBasicPowerstation wp : CacheContext.wpls) {
+            if (CacheContext.wppointmap.containsKey(wp.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.wppointmap.get(wp.getId());
 
-                ProEconPowerstationInfoDay6 pewp=new ProEconPowerstationInfoDay6();
+                ProEconPowerstationInfoDay6 pewp = new ProEconPowerstationInfoDay6();
                 Initial.initial(pewp);
                 pewp.setRegionId(wp.getRegionId());
                 pewp.setCompanyId(wp.getCompanyId());
@@ -423,19 +404,18 @@ public class WindPowerInfo6Service {
                 pewp.setLocation(Location.wp.getValue());
 
                 //昨日的统计结果
-                List<ProEconPowerstationInfoDay6> pepid1ls =new ArrayList<>();
-                Calendar cl=Calendar.getInstance();
+                List<ProEconPowerstationInfoDay6> pepid1ls = new ArrayList<>();
+                Calendar cl = Calendar.getInstance();
                 cl.setTime(recordDate);
-                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-
-                {
+                if (cl.get(Calendar.DAY_OF_MONTH) != 1) {
                     pepid1ls = proEconPowerstationInfoDay6Service.list().stream()
                             .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                    && i.getLocation().equals(Location.wp.getValue())
                                     && i.getWindpowerstationId().equals(wp.getId())
-                                    && i.getLocation().equals(Location.wp.getValue()))
+                                  )
                             .collect(Collectors.toList());
                 }
-                extracted(end, begin, pointmap, pewp,pepid1ls);
+                extracted(end, begin, pointmap, pewp, pepid1ls);
 //*******************************************年信息统计*********************************************************/
 //                wpinfodayls.add(pewp);
                 proEconPowerstationInfoDay6Service.save(pewp);
@@ -451,16 +431,16 @@ public class WindPowerInfo6Service {
      * 计算项目日信息
      */
     public void calProjectInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
-        Date end=c.getTime();
+        Date end = c.getTime();
 
-        Date begin= DateUtils.truncate(c.getTime());
+        Date begin = DateUtils.truncate(c.getTime());
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay6Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.pjmap.containsKey(i.getProjectId())
                         && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay6::getId)
                 .collect(Collectors.toList());
@@ -470,13 +450,16 @@ public class WindPowerInfo6Service {
             proEconPowerstationInfoDay6Service.removeByIds(idls);
 
         }
-        for(ProBasicProject pj:CacheContext.pjls)
-        {
-            if(CacheContext.wppointmap.containsKey(pj.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(pj.getId());
-
-                ProEconPowerstationInfoDay6 pewp=new ProEconPowerstationInfoDay6();
+        for (ProBasicProject pj : CacheContext.pjls) {
+            if (CacheContext.propointmap.containsKey(pj.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.propointmap.get(pj.getId());
+
+                ProEconPowerstationInfoDay6 pewp = new ProEconPowerstationInfoDay6();
+                if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
+                    ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
+                    pewp.setRegionId(wp.getRegionId());
+                    pewp.setCompanyId(wp.getCompanyId());
+                }
                 Initial.initial(pewp);
                 pewp.setForeignKeyId("0");
                 pewp.setWindpowerstationId(pj.getWindpowerstationId());
@@ -485,19 +468,19 @@ public class WindPowerInfo6Service {
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
 
                 //昨日的统计结果
-                List<ProEconPowerstationInfoDay6> pepid1ls =new ArrayList<>();
-                Calendar cl=Calendar.getInstance();
+                List<ProEconPowerstationInfoDay6> pepid1ls = new ArrayList<>();
+                Calendar cl = Calendar.getInstance();
                 cl.setTime(recordDate);
-                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-
-                {
+                if (cl.get(Calendar.DAY_OF_MONTH) != 1) {
                     pepid1ls = proEconPowerstationInfoDay6Service.list().stream()
                             .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                    && i.getLocation().equals(Location.pj.getValue())
                                     && i.getProjectId().equals(pj.getId())
-                                    && i.getLocation().equals(Location.pj.getValue()))
+
+                            )
                             .collect(Collectors.toList());
                 }
-                extracted(end, begin, pointmap, pewp,pepid1ls);
+                extracted(end, begin, pointmap, pewp, pepid1ls);
 
 
                 proEconPowerstationInfoDay6Service.save(pewp);
@@ -508,22 +491,23 @@ public class WindPowerInfo6Service {
         }
 
     }
+
     /**
      * 计算线路日信息
      */
     public void calLineInfoDay(Date recordDate) throws Exception {
-        Calendar c=Calendar.getInstance();
+        Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
-        Date end=c.getTime();
+        Date end = c.getTime();
 
-        Date begin= DateUtils.truncate(c.getTime());
+        Date begin = DateUtils.truncate(c.getTime());
 
         //判断是否有重复记录,先删除重复记录
         List<String> idls = proEconPowerstationInfoDay6Service.list().stream()
-                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
                         && CacheContext.lnmap.containsKey(i.getLineId())
-                        && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay6::getId)
+                        && i.getLocation().equals(Location.ln.getValue())).map(ProEconPowerstationInfoDay6::getId)
                 .collect(Collectors.toList());
 
         if (idls.size() > 0) {
@@ -531,13 +515,21 @@ public class WindPowerInfo6Service {
             proEconPowerstationInfoDay6Service.removeByIds(idls);
 
         }
-        for(ProBasicLine ln:CacheContext.lnls)
-        {
-            if(CacheContext.wppointmap.containsKey(ln.getId()))
-            {
-                Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(ln.getId());
+        for (ProBasicLine ln : CacheContext.lnls) {
+            if (CacheContext.linepointmap.containsKey(ln.getId())) {
+                Map<String, ProBasicPowerstationPoint> pointmap = CacheContext.linepointmap.get(ln.getId());
+
+                ProEconPowerstationInfoDay6 pewp = new ProEconPowerstationInfoDay6();
+                if (CacheContext.pjmap.containsKey(ln.getProjectId())) {
+                    ProBasicProject pj = CacheContext.pjmap.get(ln.getProjectId());
+                    if (CacheContext.wpmap.containsKey(pj.getWindpowerstationId())) {
+                        ProBasicPowerstation wp = CacheContext.wpmap.get(pj.getWindpowerstationId());
+                        pewp.setRegionId(wp.getRegionId());
+                        pewp.setCompanyId(wp.getCompanyId());
+                        pewp.setWindpowerstationId(wp.getId());
+                    }
 
-                ProEconPowerstationInfoDay6 pewp=new ProEconPowerstationInfoDay6();
+                }
                 Initial.initial(pewp);
                 pewp.setForeignKeyId("0");
                 pewp.setLineId(ln.getId());
@@ -546,19 +538,18 @@ public class WindPowerInfo6Service {
                 pewp.setRecordDate(DateUtils.truncate(recordDate));
 
                 //昨日的统计结果
-                List<ProEconPowerstationInfoDay6> pepid1ls =new ArrayList<>();
-                Calendar cl=Calendar.getInstance();
+                List<ProEconPowerstationInfoDay6> pepid1ls = new ArrayList<>();
+                Calendar cl = Calendar.getInstance();
                 cl.setTime(recordDate);
-                if(cl.get(Calendar.DAY_OF_MONTH)!=1)
-
-                {
+                if (cl.get(Calendar.DAY_OF_MONTH) != 1) {
                     pepid1ls = proEconPowerstationInfoDay6Service.list().stream()
                             .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
+                                    && i.getLocation().equals(Location.ln.getValue())
                                     && i.getLineId().equals(ln.getId())
-                                    && i.getLocation().equals(Location.ln.getValue()))
-                            .collect(Collectors.toList());
+
+                            ).collect(Collectors.toList());
                 }
-                extracted(end, begin, pointmap, pewp,pepid1ls);
+                extracted(end, begin, pointmap, pewp, pepid1ls);
 
                 proEconPowerstationInfoDay6Service.save(pewp);
 
@@ -571,16 +562,13 @@ public class WindPowerInfo6Service {
 
     private void extracted(Date end, Date begin, Map<String, ProBasicPowerstationPoint> pointmap, ProEconPowerstationInfoDay6 pewp, List<ProEconPowerstationInfoDay6> pepid1ls) throws Exception {
         //*******************************************日信息统计*********************************************************/
-        if(pointmap.containsKey(ContantXk.FCCFTFS70))
-        {
-
-            ProBasicPowerstationPoint point= pointmap.get(ContantXk.FCCFTFS70);
-            if(StringUtils.notEmp(point.getNemCode()) && !point.getNemCode().equals(initialcode))
-            {
-                List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
-                if(!pointls.isEmpty())
-                {
-                    DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+        if (pointmap.containsKey(ContantXk.FCCFTFS70)) {
+
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.FCCFTFS70);
+            if (StringUtils.notEmp(point.getNemCode()) && !point.getNemCode().equals(initialcode)) {
+                List<PointData> pointls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
+                if (!pointls.isEmpty()) {
+                    DoubleSummaryStatistics summaryStatistics = pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
                     //日最大风速
                     pewp.setRzdfscft(summaryStatistics.getMax());
                     //日最小风速
@@ -588,15 +576,12 @@ public class WindPowerInfo6Service {
                     //日平均风速
                     pewp.setRpjfscft(summaryStatistics.getAverage());
                 }
-            }else
-            {
-                if(pointmap.containsKey(ContantXk.SSPJFS))
-                {
-                     point= pointmap.get(ContantXk.SSPJFS);
-                    List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
-                    if(!pointls.isEmpty())
-                    {
-                        DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+            } else {
+                if (pointmap.containsKey(ContantXk.SSPJFS)) {
+                    point = pointmap.get(ContantXk.SSPJFS);
+                    List<PointData> pointls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
+                    if (!pointls.isEmpty()) {
+                        DoubleSummaryStatistics summaryStatistics = pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
                         //日最大风速
                         pewp.setRzdfscft(summaryStatistics.getMax());
                         //日最小风速
@@ -609,14 +594,12 @@ public class WindPowerInfo6Service {
             }
 
 
-        }else if(pointmap.containsKey(ContantXk.SSPJFS))
-        {
-            ProBasicPowerstationPoint point= pointmap.get(ContantXk.SSPJFS);
+        } else if (pointmap.containsKey(ContantXk.SSPJFS)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.SSPJFS);
 
-            List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
-            if(!pointls.isEmpty())
-            {
-                DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+            List<PointData> pointls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
+            if (!pointls.isEmpty()) {
+                DoubleSummaryStatistics summaryStatistics = pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
                 //日最大风速
                 pewp.setRzdfscft(summaryStatistics.getMax());
                 //日最小风速
@@ -628,16 +611,11 @@ public class WindPowerInfo6Service {
         }
 
 
-
-
-
-        if(pointmap.containsKey(ContantXk.SSZGL))
-        {
-            ProBasicPowerstationPoint point= pointmap.get(ContantXk.SSZGL);
-            List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
-            if(!pointls.isEmpty())
-            {
-                DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
+        if (pointmap.containsKey(ContantXk.SSZGL)) {
+            ProBasicPowerstationPoint point = pointmap.get(ContantXk.SSZGL);
+            List<PointData> pointls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
+            if (!pointls.isEmpty()) {
+                DoubleSummaryStatistics summaryStatistics = pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
                 //日最大功率
                 pewp.setRzdglcx(summaryStatistics.getMax());
                 //日最小功率
@@ -652,52 +630,43 @@ public class WindPowerInfo6Service {
 
 //*******************************************月信息统计*********************************************************/
 
-        if(pepid1ls.isEmpty())
-        {
+        if (pepid1ls.isEmpty()) {
             setPowerandSpeedMonth(pewp);
-        }else
-        {
+        } else {
 
 
-            ProEconPowerstationInfoDay6 pepid=pepid1ls.get(0);
+            ProEconPowerstationInfoDay6 pepid = pepid1ls.get(0);
 
             //如果昨日大于今日最大功率
-            if(pepid.getYzdglcx()> pewp.getRzdglcx())
-            {
+            if (pepid.getYzdglcx() > pewp.getRzdglcx()) {
                 pewp.setYzdglcx(pepid.getYzdglcx());
-            }else {
+            } else {
                 pewp.setYzdglcx(pewp.getRzdglcx());
             }
             //如果昨日大于今日最大风速
-            if(pepid.getYzdfscft()> pewp.getRzdfscft())
-            {
+            if (pepid.getYzdfscft() > pewp.getRzdfscft()) {
                 pewp.setYzdfscft(pepid.getYzdfscft());
-            }else
-            {
+            } else {
                 pewp.setYzdfscft(pewp.getRzdfscft());
             }
 
             //如果昨日小于今日最小功率
-            if(pepid.getYzxglcx()< pewp.getRzxglcx())
-            {
+            if (pepid.getYzxglcx() < pewp.getRzxglcx()) {
                 pewp.setYzxglcx(pepid.getYzxglcx());
-            }else
-            {
+            } else {
                 pewp.setYzxglcx(pewp.getRzxglcx());
             }
             //如果昨日小于今日最小风速
-            if(pepid.getYzxfscft()< pewp.getRzxfscft())
-            {
+            if (pepid.getYzxfscft() < pewp.getRzxfscft()) {
                 pewp.setYzxfscft(pepid.getYzxfscft());
-            }else
-            {
+            } else {
                 pewp.setYzxfscft(pewp.getRzxfscft());
             }
-            double   pjfs = BigDecimal.valueOf(pewp.getYpjfscft() + pepid.getRpjfscft()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
+            double pjfs = BigDecimal.valueOf(pewp.getYpjfscft() + pepid.getRpjfscft()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
 
             pewp.setYzxfscft(pjfs);
 
-            double   pjgl = BigDecimal.valueOf(pewp.getYpjglcx() + pepid.getRpjglcx()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
+            double pjgl = BigDecimal.valueOf(pewp.getYpjglcx() + pepid.getRpjglcx()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
             pewp.setYzxglcx(pjgl);
 
         }
@@ -706,10 +675,9 @@ public class WindPowerInfo6Service {
 //*******************************************月信息统计*********************************************************/
 
 //*******************************************年信息统计*********************************************************/
-        if(pepid1ls.isEmpty())
-        {
+        if (pepid1ls.isEmpty()) {
             setPowerandSpeedYear(pewp);
-        }else {
+        } else {
 
             ProEconPowerstationInfoDay6 pepid = pepid1ls.get(0);
 

+ 71 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java

@@ -0,0 +1,71 @@
+package com.gyee.generation.service;
+
+
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.ProBasicEquipment;
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.gyee.generation.service.auto.IProEconWindturbineGoodnessService;
+import com.gyee.generation.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class WindturbineGoodnessService {
+
+    @Resource
+    private CoefficientService coefficientService;
+    @Resource
+    private GoodnessOfFitService goodnessOfFitService;
+    @Resource
+    private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
+
+    public void calWindturbineGoodness(Date recordDate) throws Exception {
+
+
+
+        //判断是否有重复记录,先删除重复记录
+        List<Long> idls = proEconWindturbineGoodnessService.list().stream()
+                .filter(i -> i.getRecorddate().compareTo(DateUtils.truncate(recordDate))==0
+                        && CacheContext.wtmap.containsKey(i.getWindturbineid())).map(ProEconWindturbineGoodness::getId)
+                .collect(Collectors.toList());
+
+        if (idls.size() > 0) {
+
+            proEconWindturbineGoodnessService.removeByIds(idls);
+
+        }
+
+        Map<String, Map<String, Double>> coefficientMap=coefficientService.coefficient(recordDate);
+        Map<String, Map<String,Double>> fitMap=goodnessOfFitService.goodnessOfFit(recordDate);
+
+        for(ProBasicEquipment wt: CacheContext.wtls)
+        {
+            ProEconWindturbineGoodness po=new ProEconWindturbineGoodness();
+            po.setModelid(wt.getModelId());
+            po.setWindturbineid(wt.getId());
+            po.setRecorddate(DateUtils.truncate(recordDate));
+            po.setWindtpowerstationid(wt.getWindpowerstationId());
+            if(coefficientMap.containsKey(wt.getId()))
+            {
+                Map<String, Double> map=coefficientMap.get(wt.getId());
+                po.setDaygoodness(map.get("day"));
+                po.setYeargoodness(map.get("month"));
+                po.setMonthgoodness(map.get("year"));
+            }
+            if(fitMap.containsKey(wt.getId()))
+            {
+                Map<String, Double> map=fitMap.get(wt.getId());
+                po.setDaycoefficient(map.get("day"));
+                po.setMonthcoefficient(map.get("month"));
+                po.setMonthcoefficient(map.get("year"));
+            }
+            proEconWindturbineGoodnessService.save(po);
+        }
+    }
+
+}

+ 16 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconWindturbineGoodnessService.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.service.auto;
+
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 风电机拟合优度 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2022-11-17
+ */
+public interface IProEconWindturbineGoodnessService extends IService<ProEconWindturbineGoodness> {
+
+}

+ 20 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconWindturbineGoodnessServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.service.auto.impl;
+
+import com.gyee.generation.model.auto.ProEconWindturbineGoodness;
+import com.gyee.generation.mapper.auto.ProEconWindturbineGoodnessMapper;
+import com.gyee.generation.service.auto.IProEconWindturbineGoodnessService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 风电机拟合优度 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2022-11-17
+ */
+@Service
+public class ProEconWindturbineGoodnessServiceImpl extends ServiceImpl<ProEconWindturbineGoodnessMapper, ProEconWindturbineGoodness> implements IProEconWindturbineGoodnessService {
+
+}

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

@@ -45,7 +45,7 @@ public class InitialPointGoldenXkByEqService implements IinitialPoint {
 
 
         List<ProEconTestingPoint> pointls = proEconTestingPointService.list().stream()
-                .filter(i->i.getTypeId().equals(FCJSFW) || i.getTypeId().equals(GCJSFW)).collect(Collectors.toList());
+                .filter(i->i.getTypeId().equals(FCJSFW) ).collect(Collectors.toList());
 
         List<ProEconTestingPoint> fdpointls = proEconTestingPointService.list().stream()
                 .filter(i->i.getTypeId().equals(FCJSFW) ).collect(Collectors.toList());

+ 43 - 43
realtime/generationXK-service/src/main/java/com/gyee/generation/util/realtimesource/EdosUtil.java

@@ -1710,49 +1710,49 @@ public class EdosUtil implements IEdosUtil {
                         getHistsnapSameTiem(pointid, beginDate, finalInterval, resultList);
                     }else
                     {
-                        for (PointData snapItem : list) {
-                            long subTime = snapItem.getPointTime() - finalInterval;
-                            //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
-                            // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
-                            // 则代表该时间节点快照有效,否则为0
-                            String rawUrl = baseURL + "/history/section?null=0&tagNames=" +pointid+ "&ts=" + snapItem.getPointTime() ;
-                            ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
-                            JSONObject jsonObjectSection = sectionResp.getBody();
-
-                            if (jsonObjectSection != null) {
-                                List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
-                                if (sectionlist.size() > 0) {
-                                    if(sectionlist.get(0).getPointTime()<=snapItem.getPointTime()){
-                                        resultList.add(snapItem);
-                                    }
-                                    else{
-                                        PointData data = new PointData();
-                                        data.setEdnaId(pointid);
-                                        data.setPointTime(snapItem.getPointTime());
-                                        data.setPointValue("0");
-                                        data.setPointName("1");
-                                        data.setPointValueInDouble(0.0);
-                                        resultList.add(data);
-                                    }
-                                } else {
-                                    PointData data = new PointData();
-                                    data.setEdnaId(pointid);
-                                    data.setPointTime(snapItem.getPointTime());
-                                    data.setPointValue("0");
-                                    data.setPointName("1");
-                                    data.setPointValueInDouble(0.0);
-                                    resultList.add(data);
-                                }
-                            } else {
-                                PointData data = new PointData();
-                                data.setEdnaId(pointid);
-                                data.setPointTime(snapItem.getPointTime());
-                                data.setPointValue("0");
-                                data.setPointName("1");
-                                data.setPointValueInDouble(0.0);
-                                resultList.add(data);
-                            }
-                        }
+//                        for (PointData snapItem : list) {
+//                            long subTime = snapItem.getPointTime() - finalInterval;
+//                            //查询时间区间的截面值(截面值为传入时间节点的上一个最近值,返回时间为值的真实时间),
+//                            // 再进行比较,若截面值的时间戳在以快照时间节点前推一个单位的时间区间中,
+//                            // 则代表该时间节点快照有效,否则为0
+//                            String rawUrl = baseURL + "/history/section?null=0&tagNames=" +pointid+ "&ts=" + snapItem.getPointTime() ;
+//                            ResponseEntity<JSONObject> sectionResp = restTemplate.getForEntity(rawUrl, JSONObject.class);
+//                            JSONObject jsonObjectSection = sectionResp.getBody();
+//
+//                            if (jsonObjectSection != null) {
+//                                List<PointData> sectionlist = JsonObjectHelper.phrasePointData(jsonObjectSection);
+//                                if (sectionlist.size() > 0) {
+//                                    if(sectionlist.get(0).getPointTime()<=snapItem.getPointTime()){
+//                                        resultList.add(snapItem);
+//                                    }
+//                                    else{
+//                                        PointData data = new PointData();
+//                                        data.setEdnaId(pointid);
+//                                        data.setPointTime(snapItem.getPointTime());
+//                                        data.setPointValue("0");
+//                                        data.setPointName("1");
+//                                        data.setPointValueInDouble(0.0);
+//                                        resultList.add(data);
+//                                    }
+//                                } else {
+//                                    PointData data = new PointData();
+//                                    data.setEdnaId(pointid);
+//                                    data.setPointTime(snapItem.getPointTime());
+//                                    data.setPointValue("0");
+//                                    data.setPointName("1");
+//                                    data.setPointValueInDouble(0.0);
+//                                    resultList.add(data);
+//                                }
+//                            } else {
+//                                PointData data = new PointData();
+//                                data.setEdnaId(pointid);
+//                                data.setPointTime(snapItem.getPointTime());
+//                                data.setPointValue("0");
+//                                data.setPointName("1");
+//                                data.setPointValueInDouble(0.0);
+//                                resultList.add(data);
+//                            }
+//                        }
                     }
 
                     return resultList;