Bläddra i källkod

Merge branch 'master' of http://124.70.43.205:3000/GYEE_R.D/gaia

chenminghua 1 år sedan
förälder
incheckning
a917a5afac
22 ändrade filer med 1393 tillägg och 238 borttagningar
  1. 6 0
      electricity/meter/build.gradle
  2. 10 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/adapter/Adapter.java
  3. 2 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/config/AppConfig.java
  4. 13 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/AvgData.java
  5. 13 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/MaxData.java
  6. 13 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/MinData.java
  7. 20 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/PointDatas.java
  8. 128 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/TDEquipmentMeterInfo.java
  9. 16 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/entity/vo/SisViewVO.java
  10. 77 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/mapper/TDEquipmentMeterInfoMapper.java
  11. 16 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/iService/ITDEquipmentMeterInfoService.java
  12. 27 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/impl/TDEquipmentMeterInfoServiceImpl.java
  13. 63 2
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetPowerStationInfoById.java
  14. 32 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetView.java
  15. 46 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetWindStationInfo.java
  16. 0 230
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/saveTDengine/TDSaveLLFDL1MinTest.java
  17. 896 0
      electricity/meter/src/main/java/com/gyee/gaia/meter/service/saveTDengine/TDSaveLLFDLTest.java
  18. 6 0
      electricity/meter/src/main/resources/mappers-postgresql/TDEquipmentMeterInfoMapper.xml
  19. 6 3
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/UserMarkController.java
  20. 1 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/IEquipPowerGenDayService.java
  21. 1 2
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/EquipPowerGenDayServiceImpl.java
  22. 1 1
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java

+ 6 - 0
electricity/meter/build.gradle

@@ -23,6 +23,9 @@ dependencyManagement {
     }
 }
 
+springBoot {
+    buildInfo()
+}
 dependencies {
     implementation project(":common:utils")
     implementation project(":common:data")
@@ -54,6 +57,9 @@ dependencies {
     implementation("org.apache.poi:poi:5.2.3")
     implementation ("org.apache.poi:poi-ooxml:5.2.3")
 
+    //注解处理器
+    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
+
 
 
 

+ 10 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/adapter/Adapter.java

@@ -1,6 +1,7 @@
 package com.gyee.gaia.meter.adapter;
 
 import com.gyee.gaia.meter.entity.PointData;
+import com.gyee.gaia.meter.entity.PointDatas;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -36,6 +37,15 @@ public interface Adapter {
             @RequestParam(value = "interval", required = false) Integer interval
     );
 
+    //获取一个测点指定时间段内的数据(可以设置间隔时间单位S)
+    @GetMapping("/history/stat")
+    List<PointDatas> getHistoryStat(
+            @RequestParam(value = "tagName", required = false) String tagName,
+            @RequestParam(value = "startTs", required = false) Long startTs,
+            @RequestParam(value = "endTs", required = false) Long endTs,
+            @RequestParam(value = "interval", required = false) Integer interval
+    );
+
 
     //获取一个测点指定时间段内的数据
     @GetMapping("/history/raw")

+ 2 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/config/AppConfig.java

@@ -2,11 +2,13 @@ package com.gyee.gaia.meter.config;
 
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 
 
 @Data
 @Component
+@Configuration
 @ConfigurationProperties("meter")
 public class AppConfig {
 

+ 13 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/AvgData.java

@@ -0,0 +1,13 @@
+package com.gyee.gaia.meter.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class AvgData implements Serializable {
+    private long ts;
+    private int status;
+    private double value;
+    private double doubleValue;
+}

+ 13 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/MaxData.java

@@ -0,0 +1,13 @@
+package com.gyee.gaia.meter.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class MaxData implements Serializable {
+    private long ts;
+    private int status;
+    private double value;
+    private double doubleValue;
+}

+ 13 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/MinData.java

@@ -0,0 +1,13 @@
+package com.gyee.gaia.meter.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class MinData implements Serializable {
+    private long ts;
+    private int status;
+    private double value;
+    private double doubleValue;
+}

+ 20 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/PointDatas.java

@@ -0,0 +1,20 @@
+package com.gyee.gaia.meter.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 时序数据库返回测点数据
+ * </p>
+ */
+@Data
+public class PointDatas implements Serializable {
+
+    private AvgData avg;
+    private MaxData max;
+    private MinData min;
+
+}
+

+ 128 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/TDEquipmentMeterInfo.java

@@ -0,0 +1,128 @@
+package com.gyee.gaia.meter.entity;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 风机信息(1分钟平均风速,理论功率,实际功率,理论发电量,实际发电量等)
+ * </p>
+ */
+@TableName("equipmentmeterinfo")
+@Data
+@DS("meter")
+public class TDEquipmentMeterInfo extends Model<TDEquipmentMeterInfo> implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+//    /**
+//     * 子表名
+//     */
+//    private String tbName;
+//
+//
+//    /**
+//     * 时间
+//     */
+//    private long  ts;
+//    /**
+//     * 1分钟平均风速
+//     */
+//    private double speed;
+//
+//    /**
+//     * 理论功率
+//     */
+//    private double theoreticalPower;
+//
+//    /**
+//     * 实际功率
+//     */
+//    private double actualPower;
+//
+//    /**
+//     * 理论发电量
+//     */
+//    private double TheoreticalPowerGeneration;
+//
+//    /**
+//     * 实际发电量
+//     */
+//    private double actualGeneration;
+//
+//
+//
+//
+//    /**
+//     * 型号
+//     */
+//    private String model;
+//
+//    /**
+//     * 场站
+//     */
+//    private String station;
+
+    /**
+     * 子表名
+     */
+    private String tbname;
+
+
+    /**
+     * 时间
+     */
+    private long  ts;
+    /**
+     * 1分钟平均风速
+     */
+    private double speed;
+
+    /**
+     * 实际功率
+     */
+    private double shijigonglv;
+
+    /**
+     * 理论功率
+     */
+    private double lilungonglv;
+    /**
+     * 保证功率
+     */
+    private double baozhenggonglv;
+
+    /**
+     * 实际和理论谁大用谁
+     */
+    private double shijililun;
+
+    /**
+     * 实际和保证谁大用谁
+     */
+    private double shijibaozhen;
+
+
+
+
+    /**
+     * 型号
+     */
+    private String model;
+
+    /**
+     * 场站
+     */
+    private String station;
+
+
+
+
+
+
+
+}

+ 16 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/entity/vo/SisViewVO.java

@@ -62,6 +62,22 @@ public class SisViewVO {
     //宣和发电量
     public BigDecimal xhfdl;
 
+    //日照强度
+    public BigDecimal rzqd;
+    //大武口日照强度
+    public BigDecimal dwkrzqd;
+    //平罗日照强度
+    public BigDecimal plrzqd;
+    //宣和日照强度
+    public BigDecimal xhrzqd;
+    //马场湖日照强度
+    public BigDecimal mchrzqd;
+    //海子井日照强度
+    public BigDecimal hzjrzqd;
+    //埃肯日照强度
+    public BigDecimal akrzqd;
+
+
     //月利用小时
     public BigDecimal gfylyxs;
     //年利用小时

+ 77 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/mapper/TDEquipmentMeterInfoMapper.java

@@ -0,0 +1,77 @@
+package com.gyee.gaia.meter.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.gaia.meter.entity.TDEquipmentMeterInfo;
+import com.gyee.gaia.meter.entity.TDLineFDL15Min;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+
+@Mapper
+@DS("meter")
+public interface TDEquipmentMeterInfoMapper extends BaseMapper<TDEquipmentMeterInfo> {
+
+    /**
+     * 插入数据,sql拼接字符串
+     * @param entity 后面拼的字符串
+     */
+    @Insert("insert into ${entity}")
+    int insert(String entity);
+
+
+    /**
+     * 插入数据,如果没有表则使用超级表自动建表
+     * @param tbName 子表名
+     * @param powerstationId 场站ID
+     * @param projectId 期次
+     * @param name 名称
+     * @param ts 时间戳
+     * @param bottom 底码
+     * @param meter 电量
+     */
+    @Insert("INSERT INTO #{tbName} USING equipmentmeterinfo TAGS(#{model},#{station}) VALUES (#{ts}, #{speed},#{theoreticalPower},#{actualPower},#{TheoreticalPowerGeneration},#{actualGeneration})")
+    void insertTDEquiomentMeterInfo(
+            @Param("tbName") String tbName,
+            @Param("model") String model,
+            @Param("station") String station,
+            @Param("ts") long ts,
+            @Param("speed") double speed,
+            @Param("theoreticalPower") double theoreticalPower,
+            @Param("actualPower") double actualPower,
+            @Param("TheoreticalPowerGeneration") double TheoreticalPowerGeneration,
+            @Param("actualGeneration") double actualGeneration
+
+    );
+
+    /**
+     * 插入数据,如果没有表则使用超级表自动建表
+     */
+    @Insert("INSERT INTO #{tbname} USING equipmentmeterinfo TAGS(#{model},#{station}) VALUES (#{ts}, #{speed},#{shijigonglv},#{lilungonglv},#{baozhenggonglv},#{shijililun},#{shijibaozhen})")
+    void insertTDEquiomentMeterInfo2(
+            @Param("tbname") String tbname,
+            @Param("model") String model,
+            @Param("station") String station,
+            @Param("ts") long ts,
+            @Param("speed") double speed,
+            @Param("shijigonglv") double shijigonglv,
+            @Param("lilungonglv") double lilungonglv,
+            @Param("baozhenggonglv") double baozhenggonglv,
+            @Param("shijililun") double shijililun,
+            @Param("shijibaozhen") double shijibaozhen
+
+    );
+
+
+    /**
+     * 查询
+     */
+    @Select("select tbname,* from  linefdl15min")
+    List<TDLineFDL15Min> selectLineFDL15Min1();
+
+
+}

+ 16 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/service/iService/ITDEquipmentMeterInfoService.java

@@ -0,0 +1,16 @@
+package com.gyee.gaia.meter.service.iService;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.gaia.meter.entity.TDEquipmentMeterInfo;
+
+/**
+ * <p>
+ * 公司日发电量表 服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-04-28
+ */
+public interface ITDEquipmentMeterInfoService extends IService<TDEquipmentMeterInfo> {
+
+}

+ 27 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/service/impl/TDEquipmentMeterInfoServiceImpl.java

@@ -0,0 +1,27 @@
+package com.gyee.gaia.meter.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.gaia.meter.entity.TDEquipmentMeterInfo;
+import com.gyee.gaia.meter.mapper.TDEquipmentMeterInfoMapper;
+import com.gyee.gaia.meter.mapper.TDLineFDL15MinMapper;
+import com.gyee.gaia.meter.service.iService.ITDEquipmentMeterInfoService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class TDEquipmentMeterInfoServiceImpl extends ServiceImpl<TDEquipmentMeterInfoMapper, TDEquipmentMeterInfo> implements ITDEquipmentMeterInfoService {
+
+    @Resource
+    TDLineFDL15MinMapper tdLineFDL15MinMapper;
+
+    public int saveBatch() {
+
+        int count = 0;
+
+            count += tdLineFDL15MinMapper.insert(" MHSDJL_NX_GD_MHSF_DD_P1_L1_001_ZXYG045  VALUES (NOW, 888);");
+
+        return count;
+    }
+}

+ 63 - 2
electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetPowerStationInfoById.java

@@ -3,7 +3,10 @@ package com.gyee.gaia.meter.service.meter;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.meter.adapter.Adapter;
 import com.gyee.gaia.meter.entity.MeterInfoCalculating;
+import com.gyee.gaia.meter.entity.PointData;
+import com.gyee.gaia.meter.entity.PointDatas;
 import com.gyee.gaia.meter.entity.PowerStation;
 import com.gyee.gaia.meter.entity.vo.MeterVO;
 import com.gyee.gaia.meter.service.impl.MeterInfoCalculatingServiceImpl;
@@ -15,6 +18,7 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Author: malijun
@@ -24,6 +28,8 @@ import java.util.List;
 @Service
 public class GetPowerStationInfoById {
     @Resource
+    Adapter adapter;
+    @Resource
     MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
     @Resource
     PowerStationServiceImpl powerStationService;
@@ -47,16 +53,42 @@ public class GetPowerStationInfoById {
         for (int i = 1; i <= days; i++) {
             //开始时间
             DateTime dateTime1 = DateUtil.offsetDay(beginOfMonth, i - 1);
+            DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
 
             //根据时间和code查询风场日发电量,日上网电量,日购网电量
             MeterInfoCalculating oneFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().like("code", "%_JDXLFDL_P0").eq("date", dateTime1).eq("windpowerstation_id", nemCode));
             MeterInfoCalculating oneSWDL= meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().like("code", "%F_SWDL_P0").eq("date", dateTime1).eq("windpowerstation_id", nemCode));
             MeterInfoCalculating oneGWDL= meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().like("code", "%_GWDL_P0").eq("date", dateTime1).eq("windpowerstation_id", nemCode));
 
+            BigDecimal speed = BigDecimal.valueOf(0);
+
+            if (nemCode.contains("_MHS_")){
+                Map<String, PointData> speed1 = adapter.getHistorySection("MHSFCJSFW.NX_GD_MHSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+                double value = speed1.get("MHSFCJSFW.NX_GD_MHSF_XX_XX_XXX_XXX_CI0106").getValue();
+                speed= BigDecimal.valueOf(value);
+            } else if (nemCode.contains("_NSS_")) {
+                Map<String, PointData> speed2 = adapter.getHistorySection("NSSFCJSFW.NX_GD_NSSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+                double value = speed2.get("NSSFCJSFW.NX_GD_NSSF_XX_XX_XXX_XXX_CI0106").getValue();
+                speed= BigDecimal.valueOf(value);
+            } else if (nemCode.contains("_QS_")) {
+                Map<String, PointData> speed3 = adapter.getHistorySection("QSFCJSFW.NX_GD_QSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+                double value = speed3.get("QSFCJSFW.NX_GD_QSF_XX_XX_XXX_XXX_CI0106").getValue();
+                speed= BigDecimal.valueOf(value);
+            } else if (nemCode.contains("_SBQ_")) {
+                Map<String, PointData> speed4 = adapter.getHistorySection("SBQFCJSFW.NX_GD_SBQF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+                double value = speed4.get("SBQFCJSFW.NX_GD_SBQF_XX_XX_XXX_XXX_CI0106").getValue();
+                speed= BigDecimal.valueOf(value);
+            } else if (nemCode.contains("_XS_")) {
+                Map<String, PointData> speed5 = adapter.getHistorySection("XSFCJSFW.NX_GD_XSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+                double value = speed5.get("XSFCJSFW.NX_GD_XSF_XX_XX_XXX_XXX_CI0106").getValue();
+                speed= BigDecimal.valueOf(value);
+            }
+
+
             BigDecimal rfdl = BigDecimal.valueOf(0);
             BigDecimal rswdl = BigDecimal.valueOf(0);
             BigDecimal rgwdl = BigDecimal.valueOf(0);
-            BigDecimal speed = BigDecimal.valueOf(0);
+
 
             if (oneFDL != null) {
                 rfdl = oneFDL.getValue();
@@ -171,6 +203,7 @@ public class GetPowerStationInfoById {
         for (int i = 1; i <= days; i++) {
             //开始时间
             DateTime dateTime1 = DateUtil.offsetDay(beginOfMonth, i - 1);
+            DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
 
             //根据时间和code查询光场日发电量,日上网电量
             MeterInfoCalculating oneFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>()
@@ -182,10 +215,37 @@ public class GetPowerStationInfoById {
                     .eq("date", dateTime1)
                     .eq("windpowerstation_id", nemCode));
 
+            BigDecimal speed = BigDecimal.valueOf(0);
+
+            if(nemCode.contains("_DWK_")){
+                List<PointDatas> historyStat1 = adapter.getHistoryStat("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0082", dateTime1.getTime(), dateTime2.getTime(), 86399);
+                double value = historyStat1.get(0).getAvg().getValue();
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            } else if (nemCode.contains("_PL_")) {
+                double value = 66;
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            }else if (nemCode.contains("_XH_")) {
+                List<PointDatas> historyStat3 = adapter.getHistoryStat("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0473", dateTime1.getTime(), dateTime2.getTime(), 86399);
+                double value = historyStat3.get(0).getAvg().getValue();
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            }else if (nemCode.contains("_MCH_")) {
+                List<PointDatas> historyStat4 = adapter.getHistoryStat("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0475", dateTime1.getTime(), dateTime2.getTime(), 86399);
+                double value = historyStat4.get(0).getAvg().getValue();
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            }else if (nemCode.contains("_HZJ_")) {
+                List<PointDatas> historyStat5 = adapter.getHistoryStat("HZJFGLZN.NX_GD_HZJG_YC_P1_L1_001_QXZ002", dateTime1.getTime(), dateTime2.getTime(), 86399);
+                double value = historyStat5.get(0).getAvg().getValue();
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            }else if (nemCode.contains("_AK_")) {
+                List<PointDatas> historyStat6 = adapter.getHistoryStat("AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0157", dateTime1.getTime(), dateTime2.getTime(), 86399);
+                double value = historyStat6.get(0).getAvg().getValue();
+                speed= BigDecimal.valueOf(value).setScale(2,RoundingMode.HALF_EVEN);
+            }
+
+
             BigDecimal rfdl = BigDecimal.valueOf(0);
             BigDecimal rswdl = BigDecimal.valueOf(0);
             BigDecimal rgwdl = BigDecimal.valueOf(0);
-            BigDecimal speed = BigDecimal.valueOf(0);
 
             if (oneFDL != null) {
                 rfdl = oneFDL.getValue();
@@ -195,6 +255,7 @@ public class GetPowerStationInfoById {
             }
 
 
+
             MeterVO meterVO = new MeterVO();
             meterVO.setTimestr(String.valueOf(i));
             meterVO.setDate(dateTime1);

+ 32 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetView.java

@@ -3,7 +3,9 @@ package com.gyee.gaia.meter.service.meter;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.meter.adapter.Adapter;
 import com.gyee.gaia.meter.entity.MeterInfoCalculating;
+import com.gyee.gaia.meter.entity.PointData;
 import com.gyee.gaia.meter.entity.vo.SisViewVO;
 import com.gyee.gaia.meter.service.impl.MeterInfoBottomcodeServiceImpl;
 import com.gyee.gaia.meter.service.impl.MeterInfoCalculatingServiceImpl;
@@ -12,6 +14,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.Map;
 
 /**
  * Author: malijun
@@ -23,6 +26,8 @@ public class GetView {
     MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
     @Resource
     MeterInfoBottomcodeServiceImpl meterInfoBottomcodeService;
+    @Resource
+    Adapter adapter;
 
     public SisViewVO getView() {
 
@@ -186,6 +191,33 @@ public class GetView {
         );
         sisViewVO.setXhfdl(oneXHFDL.getValue());
 
+        //大武口日照强度
+        Map<String, PointData> historyLatest1 = adapter.getHistoryLatest("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0082");
+        sisViewVO.setDwkrzqd(BigDecimal.valueOf(historyLatest1.get("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0082").getValue()).setScale(4,RoundingMode.HALF_EVEN));
+
+        //平罗日照强度
+//        Map<String, PointData> historyLatest2 = adapter.getHistoryLatest("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0082");
+        sisViewVO.setPlrzqd(BigDecimal.valueOf(66));
+
+        //宣和日照强度
+        Map<String, PointData> historyLatest3 = adapter.getHistoryLatest("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0473");
+        sisViewVO.setXhrzqd(BigDecimal.valueOf(historyLatest3.get("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0473").getValue()).setScale(4,RoundingMode.HALF_EVEN));
+
+        //马场湖日照强度
+        Map<String, PointData> historyLatest4 = adapter.getHistoryLatest("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0475");
+        sisViewVO.setMchrzqd(BigDecimal.valueOf(historyLatest4.get("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0475").getValue()).setScale(4,RoundingMode.HALF_EVEN));
+
+        //海子井日照强度
+        Map<String, PointData> historyLatest5 = adapter.getHistoryLatest("HZJFGLZN.NX_GD_HZJG_YC_P1_L1_001_QXZ002");
+        sisViewVO.setHzjrzqd(BigDecimal.valueOf(historyLatest5.get("HZJFGLZN.NX_GD_HZJG_YC_P1_L1_001_QXZ002").getValue()).setScale(4,RoundingMode.HALF_EVEN));
+
+        //埃肯日照强度
+        Map<String, PointData> historyLatest6 = adapter.getHistoryLatest("AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0157");
+        sisViewVO.setAkrzqd(BigDecimal.valueOf(historyLatest6.get("AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0157").getValue()).setScale(4,RoundingMode.HALF_EVEN));
+
+        sisViewVO.setRzqd(sisViewVO.getDwkrzqd().add(sisViewVO.getPlrzqd()).add(sisViewVO.getXhrzqd()).add(sisViewVO.getMchrzqd()).add(sisViewVO.getHzjrzqd()).add(sisViewVO.getAkrzqd()).divide(BigDecimal.valueOf(5),RoundingMode.HALF_EVEN));
+
+
 
         //总
         //装机容量

+ 46 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/service/meter/GetWindStationInfo.java

@@ -3,7 +3,10 @@ package com.gyee.gaia.meter.service.meter;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.meter.adapter.Adapter;
 import com.gyee.gaia.meter.entity.MeterInfoCalculating;
+import com.gyee.gaia.meter.entity.PointData;
+import com.gyee.gaia.meter.entity.PointDatas;
 import com.gyee.gaia.meter.entity.PowerStation;
 import com.gyee.gaia.meter.entity.vo.MeterVO;
 import com.gyee.gaia.meter.service.impl.MeterInfoCalculatingServiceImpl;
@@ -15,6 +18,7 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Author: malijun
@@ -24,6 +28,8 @@ import java.util.List;
 @Service
 public class GetWindStationInfo {
     @Resource
+    Adapter adapter;
+    @Resource
     MeterInfoCalculatingServiceImpl meterInfoCalculatingService;
     @Resource
     PowerStationServiceImpl powerStationService;
@@ -44,12 +50,25 @@ public class GetWindStationInfo {
         for (int i = 1; i <= days; i++) {
             //开始时间
             DateTime dateTime1 = DateUtil.offsetDay(beginOfMonth, i - 1);
+            DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
 
             //根据时间和code查询总风场日发电量,日上网电量,日购网电量
             MeterInfoCalculating oneFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONFDL_DAY").eq("date", dateTime1));
             MeterInfoCalculating oneSWDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONSWDL_DAY").eq("date", dateTime1));
             MeterInfoCalculating oneGWDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_WINDSTATIONGWDL_DAY").eq("date", dateTime1));
 
+            Map<String, PointData> speed1 = adapter.getHistorySection("MHSFCJSFW.NX_GD_MHSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+            Map<String, PointData> speed2 = adapter.getHistorySection("NSSFCJSFW.NX_GD_NSSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+            Map<String, PointData> speed3 = adapter.getHistorySection("QSFCJSFW.NX_GD_QSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+            Map<String, PointData> speed4 = adapter.getHistorySection("SBQFCJSFW.NX_GD_SBQF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+            Map<String, PointData> speed5 = adapter.getHistorySection("XSFCJSFW.NX_GD_XSF_XX_XX_XXX_XXX_CI0106",dateTime2.getTime());
+            double value1 = speed1.get("MHSFCJSFW.NX_GD_MHSF_XX_XX_XXX_XXX_CI0106").getValue();
+            double value2 = speed2.get("NSSFCJSFW.NX_GD_NSSF_XX_XX_XXX_XXX_CI0106").getValue();
+            double value3 = speed3.get("QSFCJSFW.NX_GD_QSF_XX_XX_XXX_XXX_CI0106").getValue();
+            double value4 = speed4.get("SBQFCJSFW.NX_GD_SBQF_XX_XX_XXX_XXX_CI0106").getValue();
+            double value5 = speed5.get("XSFCJSFW.NX_GD_XSF_XX_XX_XXX_XXX_CI0106").getValue();
+            double v = (value1 + value2 + value3 + value4 + value5)/5;
+
             //初始化
             BigDecimal rfdl = BigDecimal.valueOf(0);
             BigDecimal rswdl = BigDecimal.valueOf(0);
@@ -67,6 +86,10 @@ public class GetWindStationInfo {
             if (oneGWDL != null) {
                 rgwdl = oneGWDL.getValue();
             }
+            if (speed1 != null) {
+                speed = BigDecimal.valueOf(v).setScale(2,RoundingMode.HALF_EVEN);
+            }
+
 
             //VO对象设置属性值
             MeterVO meterVO = new MeterVO();
@@ -168,11 +191,30 @@ public class GetWindStationInfo {
         for (int i = 1; i <= days; i++) {
             //开始时间
             DateTime dateTime1 = DateUtil.offsetDay(beginOfMonth, i - 1);
+            DateTime dateTime2 = DateUtil.endOfDay(dateTime1);
 
             //根据时间和code查询总风场日发电量,日上网电量,日购网电量
             MeterInfoCalculating oneFDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_GFFDL_DAY").eq("date", dateTime1));
             MeterInfoCalculating oneSWDL = meterInfoCalculatingService.getOne(new QueryWrapper<MeterInfoCalculating>().eq("code", "DL.NX_GD_GFSWDL_DAY").eq("date", dateTime1));
 
+
+            List<PointDatas> historyStat1 = adapter.getHistoryStat("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0082", dateTime1.getTime(), dateTime2.getTime(), 86399);
+//         平罗没点
+            List<PointDatas> historyStat3 = adapter.getHistoryStat("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0473", dateTime1.getTime(), dateTime2.getTime(), 86399);
+            List<PointDatas> historyStat4 = adapter.getHistoryStat("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0475", dateTime1.getTime(), dateTime2.getTime(), 86399);
+            List<PointDatas> historyStat5 = adapter.getHistoryStat("HZJFGLZN.NX_GD_HZJG_YC_P1_L1_001_QXZ002", dateTime1.getTime(), dateTime2.getTime(), 86399);
+            List<PointDatas> historyStat6 = adapter.getHistoryStat("AKDQ.NX_GD_AKG_DQ_P1_L1_001_AI0157", dateTime1.getTime(), dateTime2.getTime(), 86399);
+            double value1 = historyStat1.get(0).getAvg().getValue();
+//            double value2 = historyStat2.get(0).getAvg().getValue();
+            double value2 = 66;
+            double value3 = historyStat3.get(0).getAvg().getValue();
+            double value4 = historyStat4.get(0).getAvg().getValue();
+            double value5 = historyStat5.get(0).getAvg().getValue();
+            double value6 = historyStat6.get(0).getAvg().getValue();
+            double v = (value1 + value2 + value3 + value4 + value5+value6)/6;
+
+
+
             //初始化
             BigDecimal rfdl = BigDecimal.valueOf(0);
             BigDecimal rswdl = BigDecimal.valueOf(0);
@@ -186,6 +228,10 @@ public class GetWindStationInfo {
             if (oneSWDL != null) {
                 rswdl = oneSWDL.getValue();
             }
+            if (historyStat1 != null) {
+                speed = BigDecimal.valueOf(v).setScale(2,RoundingMode.HALF_EVEN);
+            }
+
 
 
             //VO对象设置属性值

+ 0 - 230
electricity/meter/src/main/java/com/gyee/gaia/meter/service/saveTDengine/TDSaveLLFDL1MinTest.java

@@ -1,230 +0,0 @@
-package com.gyee.gaia.meter.service.saveTDengine;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.gyee.gaia.meter.adapter.Adapter;
-import com.gyee.gaia.meter.entity.Equipment;
-import com.gyee.gaia.meter.entity.ModelPowerDetails;
-import com.gyee.gaia.meter.entity.PointData;
-import com.gyee.gaia.meter.entity.TestingPoint;
-import com.gyee.gaia.meter.service.impl.EquipmentServiceImpl;
-import com.gyee.gaia.meter.service.impl.ModelPowerDetailsServiceImpl;
-import com.gyee.gaia.meter.service.impl.TestingPointServiceImpl;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Author: malijun
- * Data  : 2023: 04: 27
- **/
-@SpringBootTest
-class TDSaveLLFDL1MinTest {
-
-    @Resource
-    Adapter adapter;
-    @Resource
-    private EquipmentServiceImpl equipmentService;
-    @Resource
-    private ModelPowerDetailsServiceImpl modelPowerDetailsService;
-    @Resource
-    private TestingPointServiceImpl testingPointService;
-
-    @Value("${start.time}")
-    private String startTimeString;
-    @Value("${end.time}")
-    private String endTimeString;
-
-    /*
-     * 日理论发电量(每台风机,综合到每个场站,每个期次,每条线路)
-     * 1分钟平均风速乘model_power_details的理论功率
-     * w=pt,理论功率乘时间(kw/h)除以60为1分钟理论发电量
-     * pro_basic_equipment表中获取到所有风机,每台风机型号等
-     * uniFormCode AI022 从testing_point中获取到所有风速测点
-     * 从适配器中取1分钟平均风速,根据风速从model_power_details中取到理论功率
-     * 计算1分钟理论发电量
-     * 保存到taos数据库中
-     */
-
-    //理论发电量
-    @Test
-    public void llfdl_1Min() {
-
-        //设置取值开始时间
-        String startString = startTimeString;
-        DateTime startDateTime = DateUtil.parse(startString);
-
-        //设置取值结束时间
-        String endDateString = endTimeString;
-        DateTime endDateTime0 = DateUtil.parse(endDateString);
-        DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
-
-        //从pro_basic_equipment(实体类为Equipment)表中获取到所有风机,每台风机型号等
-        List<Equipment> equipmentList = equipmentService.list(new QueryWrapper<Equipment>()
-                .eq("spare1", "WT")
-        );
-
-        //model_power_details表中获取到所有型号各风速对应的理论功率
-        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
-
-        //遍历modelPowerDetailsList,放入map集合中,键为model_id,值为map集合,值的map集合的键为speed,值为theory_power
-        Map<String, Map<BigDecimal, Double>> map = new HashMap<>();
-        for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
-            String modelId = modelPowerDetails.getModelId();
-            double speed0 = modelPowerDetails.getSpeed();
-            BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
-            Double theoryPower = modelPowerDetails.getTheoryPower();
-
-            // 检查是否已存在该modelId的映射关系
-            if (map.containsKey(modelId)) {
-                // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
-                Map<BigDecimal, Double> innerMap = map.get(modelId);
-                innerMap.put(speed, theoryPower);
-            } else {
-                // 如果不存在,创建新的内层HashMap,并添加映射关系
-                Map<BigDecimal, Double> innerMap = new HashMap<>();
-                innerMap.put(speed, theoryPower);
-                map.put(modelId, innerMap);
-            }
-        }
-
-        //根据uniform_code=AI022从testing_point表中获取到风机的风速测点
-        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
-                .eq("uniform_code", "AI022")
-        );
-        //遍历testingPointList,把code取出放入一个string集合
-        List<String> codeList = new ArrayList<>();
-        for (TestingPoint testingPoint : testingPointList) {
-            String code = testingPoint.getCode();
-            codeList.add(code);
-        }
-
-        //新建一个map,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
-        Map<String, Map<Long, BigDecimal>> map1 = new HashMap<>();
-
-        //遍历codeList作为适配器的参数,获取到1分钟平均风速
-        for (String code : codeList) {
-            List<PointData> pointDataList = adapter.getHistorySnap(code, startDateTime.getTime(), endDateTime.getTime(), 60);
-
-            //遍历testingPointList,根据code取到风机编码thing_id
-            for (TestingPoint testingPoint : testingPointList) {
-                String code1 = testingPoint.getCode();
-                if (code.equals(code1)) {
-                    String thingId = testingPoint.getThingId();
-                    //根据thingId从equipmentList中取出型号
-                    for (Equipment equipment : equipmentList) {
-                        String nemCode = equipment.getNemCode();
-                        if (thingId.equals(nemCode)) {
-                            String modelId = equipment.getModelId();
-                            //根据modelId从map中取出map集合,键为speed,值为theory_power
-                            Map<BigDecimal, Double> map2 = map.get(modelId);
-                            //遍历pointDataList,拿到风速,根据风速从map2中取到理论功率,计算1分钟理论发电量
-                            for (PointData pointData : pointDataList) {
-                                //风速
-                                double speed0 = pointData.getValue();
-                                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
-
-                                Double theoryPower = 0.0;
-                                if (speed0 >= 3) {
-                                    //理论功率
-                                    theoryPower = map2.get(speed);
-                                }
-                                //时间
-                                DateTime dateTime = DateTime.of(pointData.getTs());
-
-
-                                BigDecimal llfdl= BigDecimal.valueOf(0);
-                                //1分钟理论发电量
-                                if(theoryPower != null){
-                                     llfdl = new BigDecimal(Double.toString(theoryPower))
-                                            .multiply(new BigDecimal(Double.toString(1)))
-                                            .divide(new BigDecimal(Double.toString(60)), 2, RoundingMode.HALF_UP);
-                                }
-
-
-                                //存入map1,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
-                                if (map1.containsKey(nemCode)) {
-                                    // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
-                                    Map<Long, BigDecimal> innerMap = map1.get(nemCode);
-                                    innerMap.put(dateTime.getTime(), llfdl);
-                                } else {
-                                    // 如果不存在,创建新的内层HashMap,并添加映射关系
-                                    Map<Long, BigDecimal> innerMap = new HashMap<>();
-                                    innerMap.put(dateTime.getTime(), llfdl);
-                                    map1.put(nemCode, innerMap);
-                                }
-
-                            }
-
-
-                        }
-                    }
-                }
-
-
-            }
-        }
-
-        HashMap<String, BigDecimal> map2 = new HashMap<>();
-        for (String key: map1.keySet() ){
-            Map<Long, BigDecimal> mapValues = map1.get(key);
-            BigDecimal llfdl= BigDecimal.valueOf(0);
-            for (BigDecimal mapValue : mapValues.values() ) {
-                llfdl=llfdl.add(mapValue);
-            }
-            map2.put(key,llfdl);
-        }
-        System.out.println(map2);
-
-        BigDecimal mhsllfdl= BigDecimal.valueOf(0);
-        BigDecimal nssllfdl= BigDecimal.valueOf(0);
-        BigDecimal qsllfdl= BigDecimal.valueOf(0);
-        BigDecimal sbqllfdl= BigDecimal.valueOf(0);
-        BigDecimal xsllfdl= BigDecimal.valueOf(0);
-
-        for (String key: map2.keySet()) {
-            if(key.contains("NX_GDDL_MHS_F_WT_")){
-                mhsllfdl=mhsllfdl.add(map2.get(key));
-            }
-            if(key.contains("NX_GDDL_NSS_F_WT_")){
-                nssllfdl=nssllfdl.add(map2.get(key));
-            }
-            if(key.contains("NX_GDDL_QS_F_WT_")){
-                qsllfdl=qsllfdl.add(map2.get(key));
-            }
-            if(key.contains("NX_GDDL_SBQ_F_WT_")){
-                sbqllfdl=sbqllfdl.add(map2.get(key));
-            }
-            if(key.contains("NX_GDDL_XS_F_WT_")){
-                xsllfdl=xsllfdl.add(map2.get(key));
-            }
-
-
-        }
-        System.out.println("麻黄山理论发电量:"+mhsllfdl.divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
-        System.out.println("牛首山理论发电量:"+nssllfdl.divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
-        System.out.println("青山理论发电量:"+qsllfdl.divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
-        System.out.println("石板泉理论发电量:"+sbqllfdl.divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
-        System.out.println("香山理论发电量:"+xsllfdl.divide(BigDecimal.valueOf(10000),4,RoundingMode.HALF_EVEN));
-
-    }
-
-}
-
-
-
-
-
-
-
-
-

+ 896 - 0
electricity/meter/src/main/java/com/gyee/gaia/meter/service/saveTDengine/TDSaveLLFDLTest.java

@@ -0,0 +1,896 @@
+package com.gyee.gaia.meter.service.saveTDengine;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.meter.adapter.Adapter;
+import com.gyee.gaia.meter.entity.*;
+import com.gyee.gaia.meter.mapper.TDEquipmentMeterInfoMapper;
+import com.gyee.gaia.meter.service.impl.EquipmentServiceImpl;
+import com.gyee.gaia.meter.service.impl.ModelPowerDetailsServiceImpl;
+import com.gyee.gaia.meter.service.impl.TDEquipmentMeterInfoServiceImpl;
+import com.gyee.gaia.meter.service.impl.TestingPointServiceImpl;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+
+/**
+ * Author: malijun
+ * Data  : 2023: 04: 27
+ **/
+@SpringBootTest
+class TDSaveLLFDLTest {
+
+    @Resource
+    Adapter adapter;
+    @Resource
+    private EquipmentServiceImpl equipmentService;
+    @Resource
+    private ModelPowerDetailsServiceImpl modelPowerDetailsService;
+    @Resource
+    private TestingPointServiceImpl testingPointService;
+
+    @Resource
+    private TDEquipmentMeterInfoMapper tdEquipmentMeterInfoMapper;
+    @Resource
+    private TDEquipmentMeterInfoServiceImpl tdEquipmentMeterInfoService;
+
+    @Value("${start.time}")
+    private String startTimeString;
+    @Value("${end.time}")
+    private String endTimeString;
+
+    /*
+     * 日理论发电量(每台风机,综合到每个场站,每个期次,每条线路)
+     * 1分钟平均风速乘model_power_details的理论功率
+     * w=pt,理论功率乘时间(kw/h)除以60为1分钟理论发电量
+     * pro_basic_equipment表中获取到所有风机,每台风机型号等
+     * uniFormCode AI022 从testing_point中获取到所有风速测点
+     * 从适配器中取1分钟平均风速,根据风速从model_power_details中取到理论功率
+     * 计算1分钟理论发电量
+     * 保存到taos数据库中
+     */
+
+    //理论发电量
+//    @Test
+//    public void llfdl_1Min() {
+//
+//        //设置取值开始时间
+//        String startString = startTimeString;
+//        DateTime startDateTime = DateUtil.parse(startString);
+//
+//        //设置取值结束时间
+//        String endDateString = endTimeString;
+//        DateTime endDateTime0 = DateUtil.parse(endDateString);
+//        DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
+//
+//        //从pro_basic_equipment(实体类为Equipment)表中获取到所有风机,每台风机型号等
+//        List<Equipment> equipmentList = equipmentService.list(new QueryWrapper<Equipment>()
+//                .eq("spare1", "WT")
+//        );
+//
+//        //model_power_details表中获取到所有型号各风速对应的理论功率
+//        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
+//
+//        //遍历modelPowerDetailsList,放入map集合中,键为model_id,值为map集合,值的map集合的键为speed,值为theory_power
+//        Map<String, Map<BigDecimal, Double>> map = new HashMap<>();
+//        for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+//            String modelId = modelPowerDetails.getModelId();
+//            double speed0 = modelPowerDetails.getSpeed();
+//            BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+//            Double theoryPower = modelPowerDetails.getTheoryPower();
+//
+//            // 检查是否已存在该modelId的映射关系
+//            if (map.containsKey(modelId)) {
+//                // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
+//                Map<BigDecimal, Double> innerMap = map.get(modelId);
+//                innerMap.put(speed, theoryPower);
+//            } else {
+//                // 如果不存在,创建新的内层HashMap,并添加映射关系
+//                Map<BigDecimal, Double> innerMap = new HashMap<>();
+//                innerMap.put(speed, theoryPower);
+//                map.put(modelId, innerMap);
+//            }
+//        }
+//
+//
+//        //根据uniform_code=AI130从testing_point表中获取到风机的实际功率测点
+//        List<TestingPoint> testingPointList1 = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI022")
+//        );
+//        //遍历testingPointList1,把code取出放入一个string集合
+//        List<String> codeList1 = new ArrayList<>();
+//        for (TestingPoint testingPoint : testingPointList1) {
+//            String code = testingPoint.getCode();
+//            codeList1.add(code);
+//        }
+//        //遍历codeList作为适配器的参数,获取到1分钟实际平均功率
+//        for (String code : codeList1) {
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//        }
+//
+//        //根据uniform_code=AI022从testing_point表中获取到风机的风速测点
+//        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI022")
+//        );
+//        //遍历testingPointList,把code取出放入一个string集合
+//        List<String> codeList = new ArrayList<>();
+//        for (TestingPoint testingPoint : testingPointList) {
+//            String code = testingPoint.getCode();
+//            codeList.add(code);
+//        }
+//
+//        //新建一个map,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
+//        Map<String, Map<Long, BigDecimal>> map1 = new HashMap<>();
+//
+//        //遍历codeList作为适配器的参数,获取到1分钟平均风速
+//        for (String code : codeList) {
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            //遍历testingPointList,根据code取到风机编码thing_id
+//            for (TestingPoint testingPoint : testingPointList) {
+//                String code1 = testingPoint.getCode();
+//                if (code.equals(code1)) {
+//                    String thingId = testingPoint.getThingId();
+//                    //根据thingId从equipmentList中取出型号
+//                    for (Equipment equipment : equipmentList) {
+//                        String nemCode = equipment.getNemCode();
+//                        if (thingId.equals(nemCode)) {
+//                            String modelId = equipment.getModelId();
+//                            //根据modelId从map中取出map集合,键为speed,值为theory_power
+//                            Map<BigDecimal, Double> map2 = map.get(modelId);
+//                            //遍历pointDataList,拿到风速,根据风速从map2中取到理论功率,计算1分钟理论发电量
+//                            for (PointDatas pointData : pointDataList) {
+//                                //风速
+//                                double speed0 = pointData.getAvg().getValue();
+//                                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+//
+//                                Double theoryPower = 0.0;
+//                                if (speed0 >= 3 && speed0 <= 25) {
+//                                    //理论功率
+//                                    theoryPower = map2.get(speed);
+//                                }
+//                                //时间
+//                                DateTime dateTime = DateTime.of(pointData.getAvg().getTs());
+//
+//
+//                                BigDecimal llfdl = BigDecimal.valueOf(0);
+//                                //1分钟理论发电量
+//                                if (theoryPower != null) {
+//                                    llfdl = new BigDecimal(Double.toString(theoryPower))
+//                                            .multiply(new BigDecimal(Double.toString(1)))
+//                                            .divide(new BigDecimal(Double.toString(60)), 2, RoundingMode.HALF_UP);
+//                                }
+//
+//
+//                                //存入map1,键为风机编码,值为map集合,值的map集合的键为时间,值为1分钟理论发电量
+//                                if (map1.containsKey(nemCode)) {
+//                                    // 如果已存在,获取对应的内层HashMap,并添加新的映射关系
+//                                    Map<Long, BigDecimal> innerMap = map1.get(nemCode);
+//                                    innerMap.put(dateTime.getTime(), llfdl);
+//                                } else {
+//                                    // 如果不存在,创建新的内层HashMap,并添加映射关系
+//                                    Map<Long, BigDecimal> innerMap = new HashMap<>();
+//                                    innerMap.put(dateTime.getTime(), llfdl);
+//                                    map1.put(nemCode, innerMap);
+//                                }
+//
+//                            }
+//
+//
+//                        }
+//                    }
+//                }
+//
+//
+//            }
+//        }
+//
+//        HashMap<String, BigDecimal> map2 = new HashMap<>();
+//        for (String key : map1.keySet()) {
+//            Map<Long, BigDecimal> mapValues = map1.get(key);
+//            BigDecimal llfdl = BigDecimal.valueOf(0);
+//            for (BigDecimal mapValue : mapValues.values()) {
+//                llfdl = llfdl.add(mapValue);
+//            }
+//            map2.put(key, llfdl);
+//        }
+//
+//        BigDecimal mhsllfdl = BigDecimal.valueOf(0);
+//        BigDecimal nssllfdl = BigDecimal.valueOf(0);
+//        BigDecimal qsllfdl = BigDecimal.valueOf(0);
+//        BigDecimal sbqllfdl = BigDecimal.valueOf(0);
+//        BigDecimal xsllfdl = BigDecimal.valueOf(0);
+//
+//        for (String key : map2.keySet()) {
+//            if (key.contains("NX_GDDL_MHS_F_WT_")) {
+//                mhsllfdl = mhsllfdl.add(map2.get(key));
+//            }
+//            if (key.contains("NX_GDDL_NSS_F_WT_")) {
+//                nssllfdl = nssllfdl.add(map2.get(key));
+//            }
+//            if (key.contains("NX_GDDL_QS_F_WT_")) {
+//                qsllfdl = qsllfdl.add(map2.get(key));
+//            }
+//            if (key.contains("NX_GDDL_SBQ_F_WT_")) {
+//                sbqllfdl = sbqllfdl.add(map2.get(key));
+//            }
+//            if (key.contains("NX_GDDL_XS_F_WT_")) {
+//                xsllfdl = xsllfdl.add(map2.get(key));
+//            }
+//
+//
+//        }
+//        System.out.println("麻黄山理论发电量:" + mhsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
+//        System.out.println("牛首山理论发电量:" + nssllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
+//        System.out.println("青山理论发电量:" + qsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
+//        System.out.println("石板泉理论发电量:" + sbqllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
+//        System.out.println("香山理论发电量:" + xsllfdl.divide(BigDecimal.valueOf(10000), 4, RoundingMode.HALF_EVEN));
+//
+//
+//    }
+
+
+    /**
+     * 理论发电量,每台风机每分钟平均风速乘机型理论功率
+     * (如果理论功率小于实际功率,用实际功率)或者1分钟理论发电量小于1分钟实际发电量,用实际发电量
+     * 1分钟平均风速
+     */
+//    @Test
+//    public void llfdl_1Min1() {
+//
+//        //设置取值开始时间
+//        String startString = startTimeString;
+//        DateTime startDateTime0 = DateUtil.parse(startString);
+//        DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
+//
+//        //设置取值结束时间
+//        String endDateString = endTimeString;
+//        DateTime endDateTime0 = DateUtil.parse(endDateString);
+//        DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
+////        DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
+//
+//        int a = 0;
+//
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
+//
+//
+//        //model_power_details表中获取到所有型号各风速对应的理论功率
+//        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
+////        System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
+//
+//        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI022")
+//        );
+////        System.out.println("testingPointList"+testingPointList);
+//
+//        //遍历testingPointList拿到code作为适配器参数
+//        for (TestingPoint testingPoint : testingPointList) {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            System.out.println("风速返回数据:" + pointDataList.size());
+//            //遍历pointDataList,取出1分钟平均风速,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                //1分钟平均风速
+//                double speed0 = pointData.getAvg().getValue();
+//                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+//
+//                //时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
+//                tdEquiomentMeterInfo.setActualPower(0);
+//                tdEquiomentMeterInfo.setTheoreticalPower(0);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//                tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
+//
+//            }
+//
+//        }
+////        System.out.println(tdEquiomentMeterInfoSpeed);
+//
+//        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI130")
+//                .eq("thing_type", "windturbine")
+//        );
+//
+//        //遍历testingPointList拿到code作为适配器参数
+//        for (TestingPoint testingPoint : testingPointList2) {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            System.out.println("实际功率返回数据:" + pointDataList.size());
+//            //遍历pointDataList,取出1分钟平均风速,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                //1分钟平均实际功率
+//                double power = pointData.getAvg().getValue();
+//
+//                //时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setActualPower(power);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//                tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
+//
+//            }
+//
+//        }
+//
+//        System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
+//
+//        System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
+//        // 遍历 tdEquiomentMeterInfoSpeed 集合
+//        for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
+//            String tbName = speedInfo.getTbName();
+//            long ts = speedInfo.getTs();
+//            BigDecimal bigDecimal1 = new BigDecimal(ts);
+//
+//            for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
+//                BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
+//                if (powerInfo.getTbName().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
+//                    a++;
+//                    speedInfo.setActualPower(powerInfo.getActualPower());
+//                    // 退出内部循环,继续查找下一个 speedInfo 对象
+//                    break;
+//                }
+//            }
+//        }
+//
+//
+//        for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+//
+//            for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+//                if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
+//                    tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getEnsurePower());
+//                }
+//            }
+//
+//
+//        }
+//        tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+////        System.out.println("tdEquiomentMeterInfos"+tdEquiomentMeterInfos.size());
+//        tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+//
+//
+//        double c = 0;
+//        double b = 0;
+//
+//        for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+//            tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
+//            tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
+//
+//            c = c + tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
+//            b = b + tDEquiomentMeterInfo.getActualGeneration();
+//        }
+//
+//
+//        System.out.println("理论发电量" + c);
+//        System.out.println("实际发电量" + b);
+//
+//
+//    }
+
+    //理论功率
+//    @Test
+//    public void llfdl_1Min2() {
+//
+//        //设置取值开始时间
+//        String startString = startTimeString;
+//        DateTime startDateTime0 = DateUtil.parse(startString);
+//        DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
+//
+//        //设置取值结束时间
+//        String endDateString = endTimeString;
+//        DateTime endDateTime0 = DateUtil.parse(endDateString);
+////        DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
+//        DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
+//
+//        int a = 0;
+//
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
+//
+//
+//        //model_power_details表中获取到所有型号各风速对应的理论功率
+//        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
+////        System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
+//
+//        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI022")
+//        );
+////        System.out.println("testingPointList"+testingPointList);
+//
+//        //遍历testingPointList拿到code作为适配器参数
+//        for (TestingPoint testingPoint : testingPointList) {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            System.out.println("风速返回数据:" + pointDataList.size());
+//            //遍历pointDataList,取出1分钟平均风速,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                //1分钟平均风速
+//                double speed0 = pointData.getAvg().getValue();
+//                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+//
+//                //时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
+//                tdEquiomentMeterInfo.setActualPower(0);
+//                tdEquiomentMeterInfo.setTheoreticalPower(0);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//                tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
+//
+//            }
+//
+//        }
+////        System.out.println(tdEquiomentMeterInfoSpeed);
+//
+//        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI130")
+//                .eq("thing_type", "windturbine")
+//        );
+//
+//        //遍历testingPointList拿到code作为适配器参数
+//        for (TestingPoint testingPoint : testingPointList2) {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            System.out.println("实际功率返回数据:" + pointDataList.size());
+//            //遍历pointDataList,取出1分钟平均风速,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                //1分钟平均实际功率
+//                double power = pointData.getAvg().getValue();
+//
+//                //时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setActualPower(power);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//                tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
+//
+//            }
+//
+//        }
+//
+//        System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
+//
+//        System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
+//        // 遍历 tdEquiomentMeterInfoSpeed 集合
+//        for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
+//            String tbName = speedInfo.getTbName();
+//            long ts = speedInfo.getTs();
+//            BigDecimal bigDecimal1 = new BigDecimal(ts);
+//
+//            for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
+//                BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
+//                if (powerInfo.getTbName().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
+//                    a++;
+//                    speedInfo.setActualPower(powerInfo.getActualPower());
+//                    // 退出内部循环,继续查找下一个 speedInfo 对象
+//                    break;
+//                }
+//            }
+//        }
+//
+//
+//        for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+//
+//            for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+//                if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
+//                        tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getTheoryPower());
+//
+//                }
+//
+//            }
+//
+//
+//        }
+//        tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+//        tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+//
+//        //日理论发电量
+//        //日实际发电量
+//        double c = 0;
+////        double b = 0;
+//        for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+////            tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
+//            tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
+//
+//            //选择功率大的
+//            tDEquiomentMeterInfo.setTheoreticalPowerGeneration(Math.max(tDEquiomentMeterInfo.getTheoreticalPower(), tDEquiomentMeterInfo.getActualPower())/60);
+//
+//
+//            c = c + tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
+////            b = b + tDEquiomentMeterInfo.getActualGeneration();
+//
+//            //保存到taos
+//            tdEquipmentMeterInfoMapper.insertTDEquiomentMeterInfo(tDEquiomentMeterInfo.getTbName(), tDEquiomentMeterInfo.getModel(), tDEquiomentMeterInfo.getStation(), tDEquiomentMeterInfo.getTs(), tDEquiomentMeterInfo.getSpeed(), tDEquiomentMeterInfo.getTheoreticalPower(), tDEquiomentMeterInfo.getActualPower(), tDEquiomentMeterInfo.getTheoreticalPowerGeneration(), tDEquiomentMeterInfo.getActualGeneration());
+//
+//        }
+//
+////        System.out.println("理论发电量" + c);
+////        System.out.println("实际发电量" + b);
+//
+//
+//    }
+
+    //并行处理优化查询速度
+//    @Test
+//    public void llfdl_1Min3() {
+//        // 设置取值开始时间
+//        DateTime startDateTime = DateUtil.beginOfDay(DateUtil.parse(startTimeString));
+//
+//        // 设置取值结束时间
+//        DateTime endDateTime = DateUtil.endOfDay(DateUtil.parse(endTimeString));
+//
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
+//        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
+//
+//        // 从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI022")
+//        );
+//
+//        // 并行获取风速数据
+//        testingPointList.parallelStream().forEach(testingPoint -> {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            // 遍历pointDataList,取出1分钟平均风速,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                // 1分钟平均风速
+//                double speed0 = pointData.getAvg().getValue();
+//                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+//
+//                // 时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
+//                tdEquiomentMeterInfo.setActualPower(0);
+//                tdEquiomentMeterInfo.setTheoreticalPower(0);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//
+//                synchronized (tdEquiomentMeterInfoSpeed) {
+//                    tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
+//                }
+//            }
+//        });
+//
+//        // 从testingPont表中根据uniform_code=AI022获取到设备风速测点
+//        List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
+//                .eq("uniform_code", "AI130")
+//                .eq("thing_type", "windturbine")
+//        );
+//
+//        // 并行获取实际功率数据
+//        testingPointList2.parallelStream().forEach(testingPoint -> {
+//            String code = testingPoint.getCode();
+//            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+//
+//            // 遍历pointDataList,取出1分钟平均实际功率,和时间
+//            for (PointDatas pointData : pointDataList) {
+//                // 1分钟平均实际功率
+//                double power = pointData.getAvg().getValue();
+//
+//                // 时间
+//                long ts0 = pointData.getAvg().getTs();
+//                long ts = DateUtil.beginOfMinute(DateTime.of(ts0)).getTime();
+//
+//                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+//                tdEquiomentMeterInfo.setTbName(testingPoint.getThingId());
+//                tdEquiomentMeterInfo.setTs(ts);
+//                tdEquiomentMeterInfo.setActualPower(power);
+//                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+//                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+//
+//                synchronized (tdEquiomentMeterInfoPower) {
+//                    tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
+//                }
+//            }
+//        });
+//
+//
+//        // 创建HashMap用于加速查找
+//        Map<String, TDEquipmentMeterInfo> powerInfoMap = new HashMap<>();
+//        for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
+//            powerInfoMap.put(powerInfo.getTbName() + "_" + powerInfo.getTs(), powerInfo);
+//        }
+//
+//        // 匹配风速和实际功率数据
+//        for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
+//            String tbName = speedInfo.getTbName();
+//            long ts = speedInfo.getTs();
+//            TDEquipmentMeterInfo powerInfo = powerInfoMap.get(tbName + "_" + ts);
+//            if (powerInfo != null) {
+//                speedInfo.setActualPower(powerInfo.getActualPower());
+//            }
+//        }
+//
+//        // 获取所有型号对应的理论功率数据
+//        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
+//
+//        // 使用HashSet提高查找速度
+//        Set<String> modelSet = new HashSet<>();
+//        for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+//            modelSet.add(modelPowerDetails.getModelId());
+//        }
+//
+//        // 匹配理论功率数据
+//        for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+//            if (modelSet.contains(tdEquiomentMeterInfo.getModel())) {
+//                for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+//                    if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
+//                        if (tdEquiomentMeterInfo.getSpeed() < 4.5) {
+//                            tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getEnsurePower());
+//                        }else {tdEquiomentMeterInfo.setTheoreticalPower(modelPowerDetails.getTheoryPower());
+//                        }
+//
+//                    }
+//                }
+//            }
+//        }
+//
+//        // 根据tbName和ts排序
+////        tdEquiomentMeterInfoPower.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+////        tdEquiomentMeterInfoSpeed.sort(Comparator.comparing(TDEquipmentMeterInfo::getTbName).thenComparing(TDEquipmentMeterInfo::getTs));
+//
+//        // 日理论发电量和日实际发电量
+//        double c = 0;
+//        double b = 0;
+//        double d = 0;
+//        for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+//            tDEquiomentMeterInfo.setTheoreticalPowerGeneration(tDEquiomentMeterInfo.getTheoreticalPower() / 60);
+//            tDEquiomentMeterInfo.setActualGeneration(tDEquiomentMeterInfo.getActualPower() / 60);
+//
+////            c += tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
+////            b += tDEquiomentMeterInfo.getActualGeneration();
+//            double c1 = tDEquiomentMeterInfo.getTheoreticalPowerGeneration();
+////            double b1 = tDEquiomentMeterInfo.getActualGeneration();
+//            c += c1;
+////            b += b1;
+////            d += Math.max(c1, b1);
+//        }
+//
+//        System.out.println("理论功率功率理论发电量: " + c);
+//        System.out.println("实际平均功率发电量: " + b);
+//        System.out.println("优化理论发电量发电量: " + d);
+//    }
+
+    //功率对比()taos
+    @Test
+    public void llfdl_1Min4() {
+
+        //设置取值开始时间
+        String startString = startTimeString;
+        DateTime startDateTime0 = DateUtil.parse(startString);
+        DateTime startDateTime = DateUtil.beginOfDay(startDateTime0);
+
+        //设置取值结束时间
+        String endDateString = endTimeString;
+        DateTime endDateTime0 = DateUtil.parse(endDateString);
+        DateTime endDateTime = DateUtil.endOfDay(endDateTime0);
+//        DateTime endDateTime = DateUtil.offsetMinute(startDateTime, 1);
+
+        int a = 0;
+
+        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfos = new ArrayList<>();
+        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoSpeed = new ArrayList<>();
+        ArrayList<TDEquipmentMeterInfo> tdEquiomentMeterInfoPower = new ArrayList<>();
+
+
+        //model_power_details表中获取到所有型号各风速对应的理论功率
+        List<ModelPowerDetails> modelPowerDetailsList = modelPowerDetailsService.list();
+//        System.out.println("modelPowerDetailsList"+modelPowerDetailsList);
+
+        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+        List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>()
+                .eq("uniform_code", "AI022")
+        );
+//        System.out.println("testingPointList"+testingPointList);
+
+        //遍历testingPointList拿到code作为适配器参数
+        for (TestingPoint testingPoint : testingPointList) {
+            String code = testingPoint.getCode();
+            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+
+            System.out.println("风速返回数据:" + pointDataList.size());
+            //遍历pointDataList,取出1分钟平均风速,和时间
+            for (PointDatas pointData : pointDataList) {
+                //1分钟平均风速
+                double speed0 = pointData.getAvg().getValue();
+                BigDecimal speed = new BigDecimal(speed0).setScale(2, RoundingMode.HALF_EVEN);
+
+                //时间
+                long ts0 = pointData.getAvg().getTs();
+                long ts = DateUtil.offsetMinute(DateUtil.beginOfMinute(DateTime.of(ts0)), 1).getTime();
+
+                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+                tdEquiomentMeterInfo.setTbname(testingPoint.getThingId());
+                tdEquiomentMeterInfo.setTs(ts);
+                tdEquiomentMeterInfo.setSpeed(speed.doubleValue());
+                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+                tdEquiomentMeterInfoSpeed.add(tdEquiomentMeterInfo);
+
+            }
+
+        }
+//        System.out.println(tdEquiomentMeterInfoSpeed);
+
+        //从testingPont表中根据uniform_code=AI022获取到设备风速测点
+        List<TestingPoint> testingPointList2 = testingPointService.list(new QueryWrapper<TestingPoint>()
+                .eq("uniform_code", "AI130")
+                .eq("thing_type", "windturbine")
+        );
+
+        //遍历testingPointList拿到code作为适配器参数
+        for (TestingPoint testingPoint : testingPointList2) {
+            String code = testingPoint.getCode();
+            List<PointDatas> pointDataList = adapter.getHistoryStat(code, startDateTime.getTime(), endDateTime.getTime(), 60);
+
+            System.out.println("实际功率返回数据:" + pointDataList.size());
+            //遍历pointDataList,取出1分钟平均风速,和时间
+            for (PointDatas pointData : pointDataList) {
+                //1分钟平均实际功率
+                double power = pointData.getAvg().getValue();
+
+                //时间
+                long ts0 = pointData.getAvg().getTs();
+                long ts = DateUtil.offsetMinute(DateUtil.beginOfMinute(DateTime.of(ts0)), 1).getTime();
+
+                TDEquipmentMeterInfo tdEquiomentMeterInfo = new TDEquipmentMeterInfo();
+                tdEquiomentMeterInfo.setTbname(testingPoint.getThingId());
+                tdEquiomentMeterInfo.setTs(ts);
+                tdEquiomentMeterInfo.setShijigonglv(power);
+                tdEquiomentMeterInfo.setModel(testingPoint.getModel());
+                tdEquiomentMeterInfo.setStation(testingPoint.getStationId());
+                tdEquiomentMeterInfoPower.add(tdEquiomentMeterInfo);
+
+            }
+
+        }
+
+        System.out.println("tdEquiomentMeterInfoSpeed" + tdEquiomentMeterInfoSpeed.size());
+
+        System.out.println("tdEquiomentMeterInfoPower" + tdEquiomentMeterInfoPower.size());
+        // 遍历 tdEquiomentMeterInfoSpeed 集合
+        for (TDEquipmentMeterInfo speedInfo : tdEquiomentMeterInfoSpeed) {
+            String tbName = speedInfo.getTbname();
+            long ts = speedInfo.getTs();
+            BigDecimal bigDecimal1 = new BigDecimal(ts);
+
+            for (TDEquipmentMeterInfo powerInfo : tdEquiomentMeterInfoPower) {
+                BigDecimal bigDecimal2 = new BigDecimal(powerInfo.getTs());
+                if (powerInfo.getTbname().equals(tbName) && bigDecimal1.equals(bigDecimal2)) {
+                    a++;
+                    speedInfo.setShijigonglv(powerInfo.getShijigonglv());
+                    // 退出内部循环,继续查找下一个 speedInfo 对象
+                    break;
+                }
+            }
+        }
+
+
+        for (TDEquipmentMeterInfo tdEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+
+            for (ModelPowerDetails modelPowerDetails : modelPowerDetailsList) {
+                if (tdEquiomentMeterInfo.getSpeed() == modelPowerDetails.getSpeed() && tdEquiomentMeterInfo.getModel().equals(modelPowerDetails.getModelId())) {
+                    tdEquiomentMeterInfo.setLilungonglv(modelPowerDetails.getTheoryPower());
+                    tdEquiomentMeterInfo.setBaozhenggonglv(modelPowerDetails.getEnsurePower());
+
+                }
+
+            }
+
+
+        }
+
+        for (TDEquipmentMeterInfo tDEquiomentMeterInfo : tdEquiomentMeterInfoSpeed) {
+
+            //实际理论选择大的
+            tDEquiomentMeterInfo.setShijililun(Math.max(tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getLilungonglv()));
+            //实际保证选择大的
+            tDEquiomentMeterInfo.setShijibaozhen(Math.max(tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getBaozhenggonglv()));
+
+
+//            b = b + tDEquiomentMeterInfo.getActualGeneration();
+
+            //保存到taos
+            tdEquipmentMeterInfoMapper.insertTDEquiomentMeterInfo2(tDEquiomentMeterInfo.getTbname(), tDEquiomentMeterInfo.getModel(), tDEquiomentMeterInfo.getStation(), tDEquiomentMeterInfo.getTs(), tDEquiomentMeterInfo.getSpeed(), tDEquiomentMeterInfo.getShijigonglv(), tDEquiomentMeterInfo.getLilungonglv(), tDEquiomentMeterInfo.getBaozhenggonglv(), tDEquiomentMeterInfo.getShijililun(), tDEquiomentMeterInfo.getShijibaozhen());
+        }
+
+//        tdEquipmentMeterInfoService.saveBatch();
+//        tdEquipmentMeterInfoService.saveOrUpdateBatch(tdEquiomentMeterInfoSpeed);
+
+
+//        System.out.println("理论发电量" + c);
+//        System.out.println("实际发电量" + b);
+
+
+    }
+
+
+    @Test
+    public void cxllfdl() {
+        List<TDEquipmentMeterInfo> list = tdEquipmentMeterInfoService.list(new QueryWrapper<TDEquipmentMeterInfo>()
+//                .eq("station", "NX_GDDL_QS_FDC_STA")
+//                .eq("station", "NX_GDDL_SBQ_FDC_STA")
+                .eq("station", "NX_GDDL_XS_FDC_STA")
+        );
+
+
+        double shijigonglv = 0;
+        double lilungonglv = 0;
+        double baozhenggonglv = 0;
+        double shijililun = 0;
+        double baozhenlilun = 0;
+
+        //遍历list集合,累加
+        for (TDEquipmentMeterInfo tDEquipmentMeterInfo : list) {
+            shijigonglv += tDEquipmentMeterInfo.getShijigonglv()/60;
+            lilungonglv += tDEquipmentMeterInfo.getLilungonglv()/60;
+            baozhenggonglv += tDEquipmentMeterInfo.getBaozhenggonglv()/60;
+            shijililun += tDEquipmentMeterInfo.getShijililun()/60;
+            baozhenlilun += tDEquipmentMeterInfo.getShijibaozhen()/60;
+        }
+
+        System.out.println("实际功率" + new BigDecimal(shijigonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
+        System.out.println("理论功率" + new BigDecimal(lilungonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
+        System.out.println("保证功率" + new BigDecimal(baozhenggonglv).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
+        System.out.println("实际理论" + new BigDecimal(shijililun).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
+        System.out.println("实保证证" + new BigDecimal(baozhenlilun).divide(BigDecimal.valueOf(10000),2,RoundingMode.HALF_EVEN));
+
+
+    }
+
+
+}
+
+
+
+
+
+
+
+
+

+ 6 - 0
electricity/meter/src/main/resources/mappers-postgresql/TDEquipmentMeterInfoMapper.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gyee.gaia.meter.mapper.TDEquipmentMeterInfoMapper">
+
+
+</mapper>

+ 6 - 3
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/controller/UserMarkController.java

@@ -86,6 +86,7 @@ public class UserMarkController {
         }
     }
 
+
     @GetMapping("/info")
     private R getInfo(@RequestParam(value = "station") String station,
                       @RequestParam(value = "windturbines", required = false) String windturbines,
@@ -117,12 +118,12 @@ public class UserMarkController {
     }
 
     @DeleteMapping("/{id}")
-    private R deleteInfo(@PathVariable String id) {
+    private R deleteInfo1(@PathVariable String id) {
         QueryWrapper<LossCapacityUserMark> lcumWrapper = new QueryWrapper<>();
         lcumWrapper.eq("id", id);
+        LossCapacityUserMark byId = lossCapacityUserMarkService.getById(id);
         boolean b = lossCapacityUserMarkService.removeById(id);
 
-        LossCapacityUserMark byId = lossCapacityUserMarkService.getById(id);
         String equipment = byId.getEquipment();
         //同时删除五损时间用户标记
         QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
@@ -138,7 +139,7 @@ public class UserMarkController {
         List<StateCause> scList = stateCauseService.list(scWrapper);
         scList = scList.stream().peek(sc -> sc.setUserFlag("")).collect(Collectors.toList());
         //更新user_flag
-        stateCauseService.saveBatch(scList);
+         stateCauseService.saveBatch(scList);
 
         calcEquipPowerGenDay.recalculationGeneratingCapacity(DateTime.of(byId.getStartTime()));
         if (b) {
@@ -147,4 +148,6 @@ public class UserMarkController {
             return R.error();
         }
     }
+
+
 }

+ 1 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/iservice/IEquipPowerGenDayService.java

@@ -16,4 +16,5 @@ import java.util.List;
 public interface IEquipPowerGenDayService extends IService<EquipPowerGenDay> {
 
     List<EquipPowerGenDay> fjjxb(String wpids, String projectids, String lineids, String beginDate, String endDate, String type, String target, String sort);
+
 }

+ 1 - 2
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/EquipPowerGenDayServiceImpl.java

@@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
-import com.gyee.gaia.electricity.wind.entity.R;
 import com.gyee.gaia.electricity.wind.init.CacheContext;
 import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
 import com.gyee.gaia.electricity.wind.mapper.EquipPowerGenDayMapper;
@@ -94,7 +93,7 @@ public class EquipPowerGenDayServiceImpl extends ServiceImpl<EquipPowerGenDayMap
                     l.setTheoryGeneration(l.getGeneratingCapacity());
                 }
             }
-            l.setCategory(String.valueOf(l.getGeneratingCapacity().divide(l.getTheoryGeneration(),2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100))));
+            l.setCategory(String.valueOf(l.getGeneratingCapacity().divide(l.getTheoryGeneration(),4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).setScale(2,RoundingMode.HALF_EVEN)));
         }).collect(Collectors.toList());
         return list;
     }

+ 1 - 1
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java

@@ -115,7 +115,7 @@ public class CauseJobHandler implements ApplicationRunner {
                     //风速
                     ArrayDeque<PointData> pointData = pdaqMap.get(pointCode);
                     v = pointData.stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
-                    if (System.currentTimeMillis()-pointData.getFirst().getTs()>5*60*1000) {
+                    if (System.currentTimeMillis()-pointData.getFirst().getTs()>30*60*1000) {
                         //如果离线或者别的原因获取不到风速,从全场实时平均风速获取
                         Map<String, PointData> latest = adapterApi.getLatest(CacheContext.stationRealMeanSpeedMap.get(CacheContext.equipMap.get(entry.getKey()).getWindpowerstationId()));
                         Iterator<PointData> iterator = latest.values().iterator();